### Random Post

### Recent Posts

### Recent Comments

### Archives

### Categories

- article (11)
- enigma (1,123)
- misc (2)
- project euler (2)
- puzzle (31)
- site news (43)
- tantalizer (31)
- teaser (3)

### Site Stats

- 168,355 hits

Programming Enigma Puzzles

27 January 2015

Posted by on **From New Scientist #2416, 11th October 2003** [link]

Your task today is to put one letter C, L, X, V or I into each of the 25 squares in the grid so that each row and each column (read downwards) forms a

differentvalid Roman numeral. The sum of the numbers in the rows is to equal the sum of the numbers in the columns. Use the smallest number of Cs you can. As a hint, one of your diagonals will be a valid Roman numeral and the other will contain only one letter.What are:

(a) the sum of the numbers in the rows (or columns); and

(b) the Arabic value of the valid diagonal?

[enigma1260]

Advertisements

%d bloggers like this:

This Python program runs in 53ms.

Solution:(a) The sum of the numbers in the rows (or the columns) is 536. (b) The Arabic value of the valid diagonal is 162.There are 5,816 ways of filling out the grid with Roman Numerals (although any solution will also appear with the rows and columns interchanged, so the are essentially 2,908 different ways to fill out the grid).

Four of these ways use only 3 C’s. These are the grids shown below (along with their reflections along the leading diagonal):

I really enjoyed this one and I tried quite a few different approaches, most using the same ‘prefix’ based approach that you adopted. I tried a pure row based approach and also on based on starting with the centre row and column. But nothing matched the speed of the alternating row/column approach that you used so I ended up with a solution that closely follows your own.

But there are (again!) some practical differences as I am not convinced that the checks you make on lines 36 and 39 are needed because we have not yet added another row (column) and we have already checked that the columns (rows) can be completed from this position when we added the previous row (column). I certainly find the same 5816 solutions without these checks (for a modified solver that doesn’t check the diagonals or the numbers of ‘C’s) although that is no guarantee that my logic here is correct.