Random Post
Recent Posts
Recent Comments
Archives
Categories
- article (11)
- enigma (1,451)
- misc (5)
- project euler (2)
- puzzle (90)
- puzzle# (91)
- site news (65)
- tantalizer (132)
- teaser (7)
- today (1)
Site Stats
- 266,432 hits
Programming Enigma Puzzles
From New Scientist #1695, 16th December 1989 [link]
The quiet town of Spirechester is divided into nine square parishes as shown on the map. Each parish church has its spire precisely at the centre of the parish, and these are marked by crosses on the map.
The churches are named after St Agnes, St Brigid, St Cecilia, St Donwen, St Etheldreda, St Felicity, St Genevieve, St Helen and St Isabel. Each spire is topped by a weather vane which has, instead of a cock, the initial letter of its saint’s name.
Recently I walked in the meadows which surround the town and took a number of photos from different positions. Fortunately, no spire was ever hidden by another spire and the wind was such that the weather vane letters were clearly visible. However, I was not sufficiently distant from the town to capture all nine spires and, in fact, each photo contains just five spires. The orders of the spires of the photos, reading from left to right, were GEIAC, EACHD, EACDH, AECHD, IFCGB.
Starting with A (for St Agnes) list the eight churches in clockwise order around the outside of the square.
[enigma543]
I supposed the walk was a circular walk at a fixed distance from the central church.
The following Python program performs the walk, stopping at defined intervals and determining the bearings for each church (relative to the central church). We collect the different left-to-right sequences of churches.
We then consider possible assignments of labels to positions, and look to see if the photos can be constructed.
Placing the central church at the origin, and the other churches at the 8 lattice points surrounding it, we find that a walk at a distance of 5 units, stopping every degree is sufficient to collect the required views.
This Python program runs in 1.8s.
Run: [ @repl.it ]
Solution: The arrangement of the churches is: A, H, F, B, D, E, G, I.
The central church is C.
Here is a diagram of the churches and possible view points from which the photos could be taken:
It is not possible to take a photograph that includes five churches but not the central church. So the central church must be included in each photograph, and from this we can see that the central church can only be C, and we can use this fact to speed up the program. Fixing A and C and trying the remaining permutations brings the run time down to a much more reasonable 730ms (see [ @repl.it ]).