Home > Uncategorized > Rabbits and Clocks

Rabbits and Clocks

This post is inspired by a tweet from Clifford Pickover regarding Fibonacci clock.

I sought to simulate this clock. Note the pattern for a given times is not unique for the most part but this adds interest to changing patterns.

Here is the code of my attempt:

sc = Rectangle @@@ {{{2, 3}, {3, 4}}, {{2, 4}, {3, 5}}, {{0, 3}, {2,
5}}, {{0, 0}, {3, 3}}, {{3, 0}, {8, 5}}};
h[n_] := Module[{tu},
tu = Tuples[{0, 1}, 5];
Pick[tu, {1, 1, 2, 3, 5}.# == n & /@ tu]];
m[n_] := Module[{tu},
tu = Tuples[{0, 5}, 5];
Pick[tu, {1, 1, 2, 3, 5}.# == n & /@ tu]];
m[0] := {{0, 0, 0, 0, 0}};
h[0] := {{0, 0, 0, 0, 0}};
rh = # -> h[#] & /@ Range[0, 12];
rm = # -> m[#] & /@ Range[0, 55, 5];
col = {0 -> White, 1 -> Red, 5 -> Green, 6 -> Blue};
clck[hr_, mn_] := Module[{ch, cm, cl},
ch = RandomChoice[hr /. rh];
cm = RandomChoice[mn /. rm];
cl = (ch + cm) /. col;
Graphics[Prepend[Riffle[cl, sc], EdgeForm[Black]]]
]
tm = Rest@Tuples[{Range[0, 12], Range[0, 55, 5]}];
clcanim =
Column /@
Thread[{clck @@@ tm,
Row[{#1, ":", IntegerString[#2, 10, 2]}] & @@@ tm}];

The animation was made from clcanim
fc

Advertisements
Categories: Uncategorized
  1. No comments yet.
  1. May 10, 2015 at 8:37 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: