A very strange monkey
Dec. 28th, 2007 06:15 pm![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
The rarest present I got this year would have to be "Consul, the Educated Monkey".
It's a small tin plate with a monkey on it, over a chart of numbers. You move the feet of the monkey to point at two numbers, and, through scissor action, his hands point at those numbers' product in the chart. Here's another picture, and another.
So aside from a very odd gift, this would make a nifty programming puzzle. So, here one is: generate the chart printed behind the monkey. Make a program that generates it for any upper limit of numbers.
For reference, here's the chart (printed from my program to do this):
The numbers on the bottom go from 1 to 12, and the little square on the far right means, obviously, "square the number". For bonus points, make the program print the chart for any arbitrary operation on two numbers, like print an addition chart like this, or a modulus chart. In this case, the square should just act as if it is whatever the other foot is pointing at. Don't worry about spacing, I had to resort to HTML to get it to line up. Just generating the right numbers is enough.
I'll make another post in a few days with code and explanation.
no subject
Date: 2007-12-29 01:35 pm (UTC)(no subject)
From:no subject
Date: 2008-01-09 10:50 am (UTC)Here's the ruby function which creates the array of numbers in line(i)
And here's the code which prints out your centred pyramid...
It's like a rag to a bull, it really is... ;)