Sunday Times Brainteaser – Noughts and Crosses
by Miss W. M. Jeffree
Published 23rd December 1956 (link)
Each square is to be occupied by either a zero or a cross, which stands for one particular digit which you may discover for yourself.
No row or column begins with a zero.
The following clues give the prime factors of the various rows and columns, each letter representing a different prime:
|(i)||a b c d|
|(ii)||a² b² e f|
|(iii)||a b² g h|
|(iv)||a b i j² k|
|(v)||a² b e j l|
|(vi)||a b² i k m|
|(i)||a b² i j k m|
|(ii)||a² b e i j² k|
|(iii)||a b² m n p|
|(iv)||a² b c d e|
|(v)||a b i j k l|
3 Comments Leave one →
This teaser provided a nice exercise in using the new pattern matching facility introduced in Python 10. It also uses my number theory library (see here)
– (iii) is not correct in the puzzle description.
– you don’t seem to use the early determination of a and b (nice idea to determine variable a from crossing first row and column).
– the check for no zeros in the first row could have been done earlier in the r4 loop (however, I know you like esthetically pleasing code).
– output is a bit confusing as it looks like n and p have fixed values where as you only know the value of n x p.
Thanks for picking up the error in the description.
I didn’t see an earlier way of determining a and b 🙁
I agree that the zeros check could be done earlier but it doesn’t really fit neatly
in the earlier loop.
The n and p issue is annoying but the way these two are found is different and
its not easy to show the order ambiguity (a more complex replacement for line
96 might be possible).
PS: I have now updated the code to display the ambiguity in n and p. I also found that the use of pattern matching in the column reconstruction was a considerable overkill and was slow when compared with the simpler approach I am now using. This got the run time down to 14 milliseconds from around 50 previously.