### Random Post

### Recent Posts

### Recent Comments

### Archives

### Categories

- article (11)
- enigma (1,183)
- misc (2)
- project euler (2)
- puzzle (46)
- site news (46)
- tantalizer (49)
- teaser (3)

### Site Stats

- 184,820 hits

Advertisements

Programming Enigma Puzzles

26 June 2015

Posted by on **From New Scientist #1438, 10th January 1985** [link]

Throwing two dice will give you a number from 2 to 12. Of course, some numbers are more likely that others. The probability of 2 for instance is 1/36; of 3 is 2/36; of 4 is 3/36; …; of 7 is 6/36; …; of 8 is 5/36; …; of 12 is 1/36.

That is true of two ordinary 6-sided dice, each bearing the letters of ENIGMA (which stand for the numbers one to six).

It is also true of this special pair of dice I have made — one with 9 sides bearing the letters IMAGINING, the other with 4 sides bearing the letters of GAGS. (S is a positive integer).

I’m not going to tell you how I constructed 9-sided and 4-sided dice. But I did, and they are fair dice. Can you interpret the MEANINGS of these fascinating facts?

[enigma290]

Advertisements

%d bloggers like this:

This Python code runs in 49ms.

Solution:MEANINGS = 56123247.So the 9-sided die has values 1, 2, 2, 3, 3, 3, 4, 4, 5. And the 4-sided die has values 1, 4, 4, 7.

Without the analysis from the 2 and 12 cases the same program examining all the possible permutations of values for ENIGMA from 1 to 6 and S from 1 to 7 runs in 113ms.

A Funny Dice problem involving non standard dice was published in the Sunday Times in March this year. The ensuing discussion involved one contributor alerting me to an interesting mathematical approach for solving puzzles of this general type. Here is a solution to this enigma teaser using the approach (it requires my number theory and polynomial libraries).

It takes a lot more effort to program (and is slower too) but the maths is elegant and that appeals to me.

Here’s a MiniZinc solution of #290: http://hakank.org/dice_with_a_difference_enigma_290.mzn

I especially like the declarative constraints of this.

And here’s a MiniZinc model of the Funny Dice problem, using the same basic approach for calculating the probabilities (though now they are decision variables instead of constants): http://hakank.org/minizinc/funny_dice.mzn

Gecode solves this in 48ms using “var int”, or 36ms when using var 1..12 as the domains.

Related: The Nontransitive dice problem (with some explorations): http://hakank.org/minizinc/nontransitive_dice.mzn