[chbot] New chocolate fish challenge

William Fleete fleetwil at gmail.com
Wed Nov 19 03:36:47 GMT 2014


6 bit bin counter in hardware pulse an output line read back 6 bits of the parallel IO port until its 60 using 7'th as the pulse line :P

Sent from my iPad

> On 19/11/2014, at 16:30, Mark Atherton <markaren1 at xtra.co.nz> wrote:
> 
> A 64 bit int with shift, bit test, and re-load would work, but that needs an 8 byte storage quantity...
> 
> So it has to be written in C ? Assembler not allowed ? :)
> 
> should be possible to build a 6 bit counter using xors and tests - basically making a counter using cascaded T type flip flops with lookahead carry etc. not sure if that can be done in 10 lines of code...
> 
> I think the brain may need plugging in backwards for this one.
> 
> -mark
> 
> 
> At 03:36 p.m. 19/11/2014, you wrote:
> 
>> 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
>> 
>> _______________________________________________
>> Chchrobotics mailing list Chchrobotics at lists.linuxnut.co.nz
>> http://lists.ourshack.com/mailman/listinfo/chchrobotics
>> Mail Archives: http://lists.ourshack.com/pipermail/chchrobotics/
>> Web site: http://kiwibots.org
>> Meetings 3rd Monday each month.
>> 
>> When replying, please edit your Subject line to reflect new content.
> 
> 
> _______________________________________________
> Chchrobotics mailing list Chchrobotics at lists.linuxnut.co.nz
> http://lists.ourshack.com/mailman/listinfo/chchrobotics
> Mail Archives: http://lists.ourshack.com/pipermail/chchrobotics/
> Web site: http://kiwibots.org
> Meetings 3rd Monday each month.
> 
> When replying, please edit your Subject line to reflect new content.



More information about the Chchrobotics mailing list