# How do I solve this odd puzzle?

I need help. Try to solve this puzzle. It's a blend of mathematics and words. The goal of word math problems is to assign each letter an integer value, 0-9. An example is below.

Example:

MAKE + KEYS = PSST


In this example: E = 3, K = 1, A = 4, Y = 5, S = 7, T = 0, M = 8, and P = 9.

When you use the integers for each variable, the math should work out correctly! The integers can not be used for 2 different letters, only one for one letter.

Real Problem: IDIOT x HEM = WORMHOLE (the x here denotes multiplication)

• I tried making a script to bruteforce this as well, but can't find any solution where each digit 0-9 maps into a single letter. Are you sure there is a solution? – votbear Dec 8 '17 at 4:09
• But i already answered this here!!.. And my answer was that there are... no possible answer!! – Brethlosze Dec 8 '17 at 5:48
• @hyprfrcb: When I asked my teacher if this is how you format it he said and I quote,"No you idiot". He said that I should format it like the problem above. When I tried to make a new problem I got replies saying that I should put it on this particular section of the website. So that's why there's a duplicate. – Oompa Loompa Dec 8 '17 at 11:50
• @shoover: My teacher typed up the instructions and I paraphrased it. I left all the critical parts in. I've double checked for the "misleading use of numeral one and capital ell, or zero versus oh" and have concluded that everything is fine. – Oompa Loompa Dec 8 '17 at 11:56
• @Everyone: There is a solution. I've asked my teacher about it 16 times in a row. – Oompa Loompa Dec 8 '17 at 12:02

There are lots of these kinds of puzzles here, in the tag. As for how to solve them, it's a matter of noticing relationships to rule out certain values, then trial and error, choosing values until you get a contradiction.

Take your simpler MAKE + KEYS = PSST example. Since there is no "carry", M and K must total 9 or less, which rules out them both being 5 or above, and later, when you know one of them, puts upper bounds on the other. It also constrains P: if they are 4 and 5, P is 9. If they were 1 and 0, P would be 1, but can't be. So you can rule out P being 1 or 0 (two different positive numbers can't add to zero.)

Some people actually write out equations:

E + S = T or T + 10
K + Y (+ maybe 1) = S or S + 10


Then they either solve simultaneous equations or just plug in some guesses.

The multiplying one is harder, and uses different relationships. So you know that

T * M = E + 10 or 20 or ....


And then there are things like "ah that means this letter must be odd" to help continue to narrow down the field.

You mentioned a teacher; are you expected to write a program to do this, or do it by hand?

• "[...], M and K must both be 5 or less" Surely 1+8 also produces no carry (assuming A+E<10). – Lolgast Dec 8 '17 at 14:59
• you're right, edited – Kate Gregory Dec 8 '17 at 15:02
• +1 on how are you expected to do this. It isn't an easy one by hand at all. (I just found people have determined that this has no solution. Something is off here.) – kaine Dec 8 '17 at 17:23

I tried this beautiful nested-loop approach:

  // IDIOT x HEM = WORMHOLE
var idiot = "00000"
var hem = "000";
var wormhole = "00000000";
var permuation_check ="";

// "IDOTHEMWRL"; // all used chars, but duplicates removed.
{

calculateStuff = function()
for (var i = 0; i < 10; i++) {
console.log("1 i : " + i);
for (var d = 0; d < 10; d++) {
for (var o = 0; o < 10; o++) {
for (var t = 0; t < 10; t++) {
console.log("t : " + t);
for (var h = 0; h < 10; h++) {
for (var e = 0; e < 10; e++) {
for (var m = 0; m < 10; m++) {
for (var w = 0; w < 10; w++) {
for (var r = 0; r < 10; r++) {
for (var l = 0; l < 10; l++) {
permutation_check = ""+i+d+o+t+h+e+m+w+r+l;
idiot = parseInt("" + i + d + i + o + t);
hem = parseInt("" + h + e + m);
wormhole = parseInt("" + w + o + r + m + h + o + l + e);

if(permutation_check.indexOf(""+i) != 0 &&
permutation_check.indexOf(""+d) != 1 &&
permutation_check.indexOf(""+o) != 2 &&
permutation_check.indexOf(""+t) != 3 &&
permutation_check.indexOf(""+h) != 4 &&
permutation_check.indexOf(""+e) != 5 &&
permutation_check.indexOf(""+m) != 6 &&
permutation_check.indexOf(""+w) != 7 &&
permutation_check.indexOf(""+r) != 8 &&
permutation_check.indexOf(""+l) != 9)
{
if (idiot * hem == wormhole) {
console.log("found : " + idiot + " x " + hem + " = " + wormhole);
alert("found : " + idiot + " x " + hem + " = " + wormhole);
}
}
}
}
}
}
}
}
}
}
}
console.log("i : " + i);
}

}


It didn't find a solution. Can Letters get bigger than 9 or negative?

also, if you add all letters and remove duplicates, you get : "IDOTHEMWRL" -> "I DO THEM WRL" - is this a hidden joke maybe?

• Oh god, the nested loops hurt my eyes. Isn't there some kind of permutation library for js you can use? – Lolgast Dec 8 '17 at 12:47
• I disagree in the "beautiful" part. Beautiness, it seems, is not without a sense of relativity. – Brethlosze Dec 8 '17 at 20:18
• Why the heck the phrase "I DO THEM WRL" appeared there??? – Brethlosze Dec 8 '17 at 20:24

I wrote a script to check every permutation in accordance with your rules. There are 105 solutions for your example, but 0 solutions for your actual question. It is not solvable.