<div dir="ltr"><div>Some sort of pseudorandom number shift and xor would do this. These are used to generate longish patterns from short registers.<br><br><br></div><div>This is how some things like GPS gold codes work.<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 19, 2014 at 4:30 PM, Mark Atherton <span dir="ltr"><<a href="mailto:markaren1@xtra.co.nz" target="_blank">markaren1@xtra.co.nz</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">A 64 bit int with shift, bit test, and re-load would work, but that needs an 8 byte storage quantity...<br>
<br>
So it has to be written in C ? Assembler not allowed ? :)<br>
<br>
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...<br>
<br>
I think the brain may need plugging in backwards for this one.<br>
<br>
-mark<br>
<br>
<br>
At 03:36 p.m. 19/11/2014, you wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
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....<br>
<br>
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:<br>
<br>
int chocolate_fish(void)<br>
<br>
{<br>
<br>
  unsigned counter = 0;<br>
<br>
   if(counter == 59) {<br>
<br>
      counter = 0;<br>
<br>
      return 1;<br>
<br>
   }<br>
<br>
   counter++;<br>
<br>
   return 0;<br>
<br>
}<br>
<br>
Now to make it hard. You can't use any math operations - no addition, subtraction multiplication or division, including the increment/decrement operations.<br>
<br>
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.<br>
<br>
Mike<br>
<br>
______________________________<u></u>_________________<br>
Chchrobotics mailing list <a href="mailto:Chchrobotics@lists.linuxnut.co.nz" target="_blank">Chchrobotics@lists.linuxnut.<u></u>co.nz</a><br>
<a href="http://lists.ourshack.com/mailman/listinfo/chchrobotics" target="_blank">http://lists.ourshack.com/<u></u>mailman/listinfo/chchrobotics</a><br>
Mail Archives: <a href="http://lists.ourshack.com/pipermail/chchrobotics/" target="_blank">http://lists.ourshack.com/<u></u>pipermail/chchrobotics/</a><br>
Web site: <a href="http://kiwibots.org" target="_blank">http://kiwibots.org</a><br>
Meetings 3rd Monday each month.<br>
<br>
When replying, please edit your Subject line to reflect new content.<br>
</blockquote>
<br>
<br>
______________________________<u></u>_________________<br>
Chchrobotics mailing list <a href="mailto:Chchrobotics@lists.linuxnut.co.nz" target="_blank">Chchrobotics@lists.linuxnut.<u></u>co.nz</a><br>
<a href="http://lists.ourshack.com/mailman/listinfo/chchrobotics" target="_blank">http://lists.ourshack.com/<u></u>mailman/listinfo/chchrobotics</a><br>
Mail Archives: <a href="http://lists.ourshack.com/pipermail/chchrobotics/" target="_blank">http://lists.ourshack.com/<u></u>pipermail/chchrobotics/</a><br>
Web site: <a href="http://kiwibots.org" target="_blank">http://kiwibots.org</a><br>
Meetings 3rd Monday each month.<br>
<br>
When replying, please edit your Subject line to reflect new content.<br>
</blockquote></div><br></div>