# Alphametic puzzle for Halloween

An alphametic puzzle for Halloween:

OCT * 31 = TRICK + TREAT

951 * 31 = 14850 + 14631 = 29481

Therefore, O = 9, C = 5, T = 1, R = 4, I = 8, K = 0, E = 6, A = 3.

A few observations to make the process easier:

- T can only be 1. 999 * 31 gives a maximum value of 30969, which leads to 2*T < 3. This means T can only be 1.

- Since T is 1, multipying OCT by 31, means the ones place should be a '1'. This means K can only be '0'.

- Based on this, since '0' and '1' are already taken, R must be at least 2. Since there are 2 'R's adding together, it means the we are looking for a value above 24000. This means the lowest such value of OCT can be 781, in order to also satisfy T = 1. This also means O must be at least 7.

After that, I just did a trial and error from 781, increasing the value by 10 until I got the answer.

Note that there is another solution: I and E are interchangeable, so I = 6 and E = 8 is also valid.

• I and E are interchangeable. So, there are two solutions. Nov 3, 2020 at 14:00
• @P.-S.Park Yes, that is correct. I just decided to present one of them. I can add it in now. Nov 3, 2020 at 14:02

$$951\times31=14650+14831$$
perl -MList::Util=shuffle -e"my%h;my@a=(split//,'trickeaoxz');do{my$i=0;for(shuffle@a){$h{$_}=$i;++$i}}until(($h{o}*100+10*$h{c}+$h{t})*31==20000*$h{t}+2000*$h{r}+100*($h{e}+$h{i})+10*($h{c}+$h{a})+$h{k}+$h{t});print $_,$h{$_},$/for keys%h"