Problem 621. Cryptomath: Addition
W A I T + A L L --------- G I F T S
equals:
9 6 0 8 + 6 7 7 --------- 1 0 2 8 5
Given strings a,b,c find where a + b = c; No left hand zeros. All solutions are believed to be unique.
Beware, the test machine might time out your entry!
If you want some easier problems that build up to this one,
- random permutations of integers
- binary comparisons
- string substitution
- convert list of numbers to a scalar
Why are the above building blocks to solving this problem? Well, let's think about the simplest thing that could possibly work.
If we
- Made random mapping of the ten or less characters to the ten digits
- Converted the characters to a vector of numbers
- Converted the vector of numbers to a scalar
- Checked the scalars in the summation
- Tried again if it did not work
Eventually, we would find the correct answer. Worst case scenario, we have a one in 10! (1/3,600,000) chance of stumbling upon the answer. For the eight character case, it is 8! (1/40,320). I like those odds enough that it is worth trying.
A supplemental problem finds out which technique, methodical or random is better.
Solution Stats
Problem Comments
-
9 Comments
I saw the note regarding "No left hand zeros", but did not put it together until later that it's really a hint regarding the sum; the 'G' in gifts cannot be mapped to a 0. It's clear now, but initially I thought the remark was referring to 'ALL' not having a blank character to the left (e.g. '\ ALL') that would be 0 when mapped to digits (e.g. 0677).
No leading zeros or repeating numbers. Be careful.
% 4956 911 05867
% 9707 766 10473
% wait all gifts
The problem with randomness is that we can't be sure about the time one experiment will take. Sometimes my solution founds the mapping in less than one second, but, in others, it can take 25 seconds: blowing the time limit.
Solution Comments
Show commentsGroup

Randomness
- 11 Problems
- 19 Finishers
- Given n, create n random numbers such that their standard deviation is also n.
- Generating random matrix with given probability mass function
- Roll the Dice!
- Make a random, non-repeating vector.
- Generate a random matrix A of (1,-1)
- Create a random vector of integers with given sum
- Guess the number I'm thinking of (Part 1)
- Fibonacci Decomposition
- Cryptomath: Addition
- Break it up! Break it up!
- Balanced Ternary Numbers: Easy as |, |-, |o
Problem Recent Solvers35
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!