Random Post
Recent Posts
- Enigma 769: Magic square
- BrainTwister #19: Angular arrangements
- Enigma 767: Safety in numbers
- BrainTwister #18: The arithmetical two-step
- Enigma 774: Sting in the tail
- BrainTwister #17: Semi-one numbers
- Enigma 773: Duodecimal
- BrainTwister #16: Order, order!
- Enigma 772: Have you seen the trailer?
- BrainTwister #15: Domino strips
Recent Comments
Archives
Categories
- article (11)
- braintwister (19)
- enigma (1,718)
- enigma-book-1982 (70)
- headscratchers-book-2023 (70)
- microteasers-book-1986 (11)
- misc (7)
- project euler (2)
- puzzle (90)
- puzzle# (249)
- site news (83)
- sphinx (4)
- tantalizer (254)
- tantalizer-book-1970 (40)
- teaser (7)
- today (1)
Site Stats
- 347,477 hits
I’m not really a fan of these long-division type of problems, so I thought it might be more interesting to write a generic solver for such substituted division sum problems. It’s quite an interesting problem to tackle, and trickier than I initially expected, but I ended up with a generic class that can be used to solve several Enigma puzzles already published. I shall add it to the enigma.py library, but if you fancy a challenge you can try writing your own long division solver.
The algorithm I use looks for numbers that match the given divisor of the sum, and then goes through the intermediate subtraction sums to find single digit multiples of the divisor that match with the intermediate subtraction sums. This gives us the digits of the result, and so by considering the remainder we can deduce the dividend of the sum. We then check that all the intermediate sums fully match, and hence find possible solutions.
For this particular problem the code runs in 141ms.
Solution: The correct sum is: 47670 ÷ 77 = 619 remainder 7.
I have now replaced the [[
SubstitutedDivision()
]] solver in the enigma.py library with a more flexible version (based on the [[SubstitutedExpression()
]] solver).This puzzle can now be solved using the following run-file, which executes in 110ms.