Skip to content

modalton/LispTudes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

LispTudes: Etudes to Programming in Lisp

Devil.lisp

You’re playing a game with the Devil, with your soul at stake. You’re sitting at a circular table which has 4 coins, arranged in a diamond, at the 12, 3, 6, and 9 o’clock positions. You are blindfolded, and can never see the coins or the table.

Your goal is to get all 4 coins showing heads, by telling the devil the position(s) of some coins to flip. We call this a “move” on your part. The Devil must faithfully perform the requested flips, but may first sneakily rotate the table any number of quarter-turns, so that the coins are in different positions. You keep making moves, and the Devil keeps rotating and flipping, until all 4 coins show heads.

Example: You tell the Devil to flip the 12 o’clock and 6 o’clock positions. The devil might rotate the table a quarter turn clockwiae, and then flip the coins that have moved into the 12 o’clock and 6 o’clock positions (which were formerly at 3 o’clock and 9 o’clock). Or the Devil could have made any other rotation before flipping.

What is a shortest sequence of moves that is guaranteed to win, no matter what the initial state of the coins, and no matter what rotations the Devil applies?

Cheryl.lisp

Albert and Bernard just became friends with Cheryl, and they want to know when her birthday is. Cheryl gave them a list of 10 possible dates:

May 15 May 16 May 19 June 17 June 18 July 14 July 16 August 14 August 15 August 17

Cheryl then tells Albert and Bernard separately the month and the day of the birthday respectively.

Albert: I don’t know when Cheryl’s birthday is, but I know that Bernard does not know too.

Bernard: At first I don’t know when Cheryl’s birthday is, but I know now.

Albert: Then I also know when Cheryl’s birthday is.

So when is Cheryl’s birthday?

Sicherman.lisp

Huh. This is interesting. You know how in many games, such as craps or Monopoly, you roll two regular dice and add them up. Only the sum matters, not what either of the individual dice shows.

Right.

And some of those sums, like 8, can be made multiple ways, while 2 and 12 can only be made one way.

Yeah. 8 can be made 5 ways, so it has a 5/36 probability of occurring.

The interesting thing is that people have been playing dice games for 7,000 years. But it wasn’t until 1977 that Colonel George Sicherman asked whether is is possible to have a pair of dice that are not regular dice—that is, they don’t have (1, 2, 3, 4, 5, 6) on the six sides—but have the same distribution of sums as a regular pair—so the pair of dice would also have to have 5 ways of making 8, but it could be different ways; maybe 7+1 could be one way. Sicherman assumes that each side bears a positive integer.

And what did he find?

Wouldn’t it be more fun to figure it out for ourselves?

OK!

How could we proceed?

When in doubt, use brute force: we can write a program to enumerate the possibilities:

About

Etudes to programming in Lisp

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published