Teaser 2804: Spots before the eyes
From The Sunday Times, 19th June 2016 [link] [link]
At the opticians I was shown a sequence of six screens. On each there was a different number of spots ranging from 0 to 5 and I had to say how many I thought I could see. This was done with the left eye and then repeated with the right. The optician always used the same sequence and my answers were:
(5 2 3 4 4 3)
(4 1 4 5 2 3)In each case I got two correct. When I asked if this was the worst he’d seen, the optician showed me these three earlier sets of answers in which just one was correct in each:
(2 2 1 2 1 4)
(3 3 2 3 5 1)
(0 4 5 1 3 2)What was the correct sequence?
[teaser2804]



Jim Randell 10:33 am on 6 September 2019 Permalink |
Programatically we can consider all possible orderings of the numbers from 0 to 5, and look for a sequence that gives the appropriate number of matches in the 5 cases.
This Python program runs in 39ms.
Run: [ @repl.it ]
from enigma import subsets, irange, printf # sequences, values to check ss = ( ((5, 2, 3, 4, 4, 3), 2), ((4, 1, 4, 5, 2, 3), 2), ((2, 2, 1, 2, 1, 4), 1), ((3, 3, 2, 3, 5, 1), 1), ((0, 4, 5, 1, 3, 2), 1), ) # count matches def check(s1, s2): return sum(a == b for (a, b) in zip(s1, s2)) # consider possible sequences for s in subsets(irange(0, 5), size=len, select="P"): if all(check(s, t) == n for (t, n) in ss): printf("{s}")Solution: The correct sequence is (4 2 0 1 5 3).
LikeLike
GeoffR 11:00 am on 6 October 2020 Permalink |
LikeLike