Brain-Teaser 495: [Goal scorers]
From The Sunday Times, 22nd November 1970 [link]
All five forwards (numbers 7-11) scored in their team’s eight-nil win. Their names, alphabetically, were Alan, Bob, Craig, Dave and Eric.
Five goals were kicked (number 10 scoring the last of just three consecutive ones). Dave headed his second goal. He and two other forwards scored two goals each — heading one and kicking the other. Successive goals were scored by the other two forwards. No player scored two consecutive goals.
The scores, in scoring order, were:
1st goal: Number 11
2nd goal: Alan
3rd goal: Eric
4th goal: Number 8
5th goal: Bob
6th goal: Number 7
7th goal: Dave
8th goal: Number 9What was each forward’s number?
This puzzle was originally published with no title.
[teaser495]
Jim Randell 7:18 am on 25 August 2019 Permalink |
This Python program runs in 95ms.
from enigma import subsets, irange, tuples, diff, update, unpack, join, printf names = "ABCDE" # m: maps number (7-11) to name A-E for s in subsets(irange(7, 11), size=len, select="P"): m = dict(zip(s, names)) # use the map to fill out the list of goal scorers ns = [ m[11], 'A', 'E', m[8], 'B', m[7], 'D', m[9] ] # no-one scored consecutive goals if any(a == b for (a, b) in tuples(ns, 2)): continue # count the number of goals scored by each n = dict((x, ns.count(x)) for x in names) # D and 2 others scored 2 goals if n['D'] != 2: continue g2s = list(x for x in names if n[x] == 2) if len(g2s) != 3: continue # the 1 goal scorers goals were consecutive g1s = diff(names, g2s) if abs(ns.index(g1s[0]) - ns.index(g1s[1])) != 1: continue # assign the kicked goals we know (1 = kick, 0 = head) k = [ None ] * 8 # D's goals are kick then head (j0, j1) = list(i for (i, x) in enumerate(ns) if x == 'D') (k[j0], k[j1]) = (1, 0) # number 10 scored the final goal of just three consecutive kicks for (i, x) in enumerate(ns): if x != m[10]: continue if i < 2: continue if k[i - 1] == 0 or k[i - 2] == 0: continue k[i] = k[i - 1] = k[i - 2] = 1 if i > 2: if k[i - 3] == 1: continue k[i - 3] = 0 if i < 7: if k[i + 1] == 1: continue k[i + 1] = 0 # fill out any remaining 5 kicked goals j = k.count(1) if j > 5: continue ms = list(i for (i, x) in enumerate(k) if x is None) for js in subsets(ms, size=5 - j, select="P"): k2 = update(k, ms, list((1 if x in js else 0) for x in ms)) # check the other scorers of 2 goals are a kick and a head if any(len(set(k2[i] for (i, x) in enumerate(ns) if x == y)) == 1 for y in diff(g2s, 'D')): continue # output solution for (k, v) in sorted(m.items(), key=unpack(lambda k, v: v)): printf("{v} = #{k}") printf("[goals = {gs}]", gs=join((n + "hk"[i] for (n, i) in zip(ns, k2)), sep=","))Solution: Alan is number 9. Bob is number 10. Craig is number 8. Dave is number 11. Eric is number 7.
The goals scored are:
LikeLike