### Random Post

### Recent Posts

### Recent Comments

### Archives

### Categories

- article (11)
- enigma (1,314)
- misc (3)
- project euler (2)
- puzzle (78)
- puzzle# (21)
- site news (54)
- tantalizer (80)
- teaser (7)

### Site Stats

- 217,167 hits

Programming Enigma Puzzles

14 November 2018

Posted by on **From New Scientist #992, 18th March 1976** [link]

Dopey confessed that he had never learnt to play chess and was appointed umpire. The other six dwarves settled down to play a five-round tournament. Grumpy drew with everyone but Sneezy and finished equal bottom with Doc, whom he had played in the first round. Sneezy drew with Doc, Happy and Sleepy. Bashful drew with Sleepy. There were no other draws.

There was at least one draw in each round and each dwarf drew in at least two consecutive rounds. The two equal winners did not play each other in the second round.

What were the pairings in the final round?

[tantalizer441]

%d bloggers like this:

As Dopey sits out we can use two letter abbreviations for the dwarves (also assuming the dwarf whose name is not given in the puzzle is “Bashful”).

I opted for a declarative approach to this puzzle, as my imperative Python code [link] was getting a bit messy (although it was a bit faster).

Here is a

MiniZincmodel for the problem.And here is a Python program to format the output (using the

minizinc.pywrapper). Overall execution time is 281ms.Solution:The matches in the final round were: Bashful vs. Sneezy; Doc vs. Sleepy; Grumpy vs. Happy.There is only one possible arrangement for the matches:

But there are three possible outcomes:

Assuming 2 points for a win, and 1 point to each player in a draw:

The joint winners, with 6 points each, are Bashful and Happy.

The joint losers, with 4 points each, are Doc and Grumpy.

And in the middle, with 5 points each, are Sleepy and Sneezy.