[chbot] New chocolate fish challenge

hamster hamster at snap.net.nz
Wed Nov 19 02:36:05 GMT 2014


 

I'm building a jumbo LED clock (using 8" 7-segment displays) for the
local pool, as I can't read a small analogue clock without my glasses
when swimming. The PCBs are on their way from China as I type.... 

So
here is the challenge. Make a C function that usually returns 0, but
returns a value of 1 once in every 60 calls calls - just like this:


int chocolate_fish(void) 

{ 

 unsigned counter = 0; 

 if(counter ==
59) { 

 counter = 0; 

 return 1; 

 } 

 counter++; 

 return 0; 

}


Now to make it hard. You can't use any math operations - no addition,
subtraction multiplication or division, including the
increment/decrement operations. 

Bonus points for using no more static
memory than one byte, and code less than 10 lines - with each statement
on a line of their own. 

Mike 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ourshack.com/pipermail/chchrobotics/attachments/20141119/bac75018/attachment.html>


More information about the Chchrobotics mailing list