Teaser 2897: Easter egg
From The Sunday Times, 1st April 2018 [link] [link]
“Granddad, I’ve got a great big Easter egg in a square box!” My grandson Liam inspired this Teaser in which I have used non-zero digits then consistently replaced them with letters, using different letters for different digits.
In this way, I have:
EASTER
(EGG)²
BOXTwo of the numbers add to make the third, and if I told you which number was largest you should be able to solve this Teaser.
Find the value of BOX.
[teaser2897]
Jim Randell 8:52 am on 22 July 2019 Permalink |
EASTER has 6 digits, (EGG)² has 5 or 6 digits, but whichever is larger BOX is the difference between them.
The alphametic expression:
only has one solution (when we don’t use the digit 0):
So this gives us our solution (BOX=362), even without needing to know which of EASTER or (EGG)² is larger. (In fact EASTER > (EGG)²).
But here is a full solution, that solves the two possible sums as alphametic problems, and looks for situations where there is a single solution for BOX. It runs in 122ms.
Run: [ @replit ]
from enigma import (SubstitutedExpression, irange, printf) # look for solutions to the alphametic sum that give a unique value for ans def check(expr, answer): p = SubstitutedExpression(expr, digits=irange(1, 9), answer=answer, verbose=0) r = set(x for (_, x) in p.solve()) if len(r) == 1: x = r.pop() printf("{answer}={x} [{expr}]") # there are two possible largest values check("sq(EGG) + BOX = EASTER", "BOX") # if EASTER is largest check("sq(EGG) - BOX = EASTER", "BOX") # if EGG^2 is largestSolution: BOX = 362.
In fact this program runs faster than the single alphametic expression above, as each alphametic expression only requires considering the possibilities for 5 digits, rather than 6 with the single sum.
If (non-leading) 0 digits are allowed, then there are three further solutions to the (EGG)² + BOX = EASTER sum (but still none for (EGG)² − BOX = EASTER).
LikeLike
GeoffR 8:52 am on 30 July 2019 Permalink |
LikeLike