Verbal arithmetic

The amount of riddles, jigsaws and puzzles that have arisen during the years is huge. Among them, mathematical puzzles constitute a category by themselves, with riddles about arithmetics, combinatorial, topology or probability. Today we will focus on the so-called verbal arithmetic or cryptarithmetic. On it, puzzles are math- ematical operations where digits have been replaced by letters, and the original numbers have to be found. ada 323 × byron ⇒ × 18504 revived 5976792 Input Each test case is an arithmetic operation (sum or product) where digits have been replaced by lowercase letters from the English alphabet. The two operands separated by a ‘+’ or ‘*’ operator are provided, followed by an equal symbol and the result of the operation, also in letters. Numbers and operators are separated by a space. The operands won’t have more than 8 lowercase letters; in addition to that, it is guaranteed that there won’t be more than 10 different letters in total. Output For each test case, the program will write the associated operation after converting letters to digits, so that everytime the same letter appears, it’s converted to the same digit and viceversa, and the arithmetical operation is correct. The solution is guaranteed to be unique. A space has to be added before and after each operator. An assignation where any of the numbers has redundant zeroes is not considered valid, but keep in mind that some of the values could be 0, which is valid. Sample Input ada * byron = revived alan * turing = intellect barack + obama = amazes donald + trump = mutant Sample Output 323 * 18504 = 5976792 2023 * 461938 = 934500574 780831 + 47828 = 828659 489634 + 12057 = 501691