Sunday Times Teaser 3045 – Let Tel Play BEDMAS Hold ‘Em!
by Stephen Hogg
Published Sunday January 31 2021 (link)
Awaiting guests on poker night, Tel placed (using only clubs, face-up, in order left-to-right) the Ace (=1) to 9 (representing numerals), then interspersed the Ten, Jack, Queen and King (representing -, +, x and ÷ respectively) in some order, but none together, among these.
This “arithmetic expression” included a value over 1000 and more even than odd numbers. Applying BEDMAS rules, as follows, gave a whole-number answer. “No Brackets or powErs, so traverse the expression, left-to-right, doing each Division or Multiplication, as encountered, then, again left-to-right, doing each Addition or Subtraction, as encountered.”
Tel’s auntie switched the King and Queen. A higher whole-number answer arose. Tel displayed the higher answer as a five-card “flush” in spades (the Jack for + followed by four numeral cards).
Give each answer.
This version does not use list comprehensions:
This alternative makes use of them:
Here is a more readable functional equivalent to line 35 above:
or better still: