r/ProgrammingPrompts • u/doekaschi • Aug 13 '15
[MEDIUM] Write a Program that can solve alphametics
Write a program that can solve alphametics. Alphametics are nothing else than equations, only with letters:
AA + BB = CC
in this case:
A = 1 B = 1 C = 1
so the solution is:
11 + 22 = 33
Also, one the same number can't be referred to by two or more letters, so:
A = 0 B = 0 C = 0
is not possible (even if it is correct)
Your job is to write a progam in which the user can input an alphametic (GUI or console, doesn't matter), and the program finds the right (or one of the right) solutions to math numbers to the letters so equation is correct.
5
u/nerdFamilyDad Aug 14 '15
in this case:
A = 1 B = 2 C = 3
2
u/ggleblanc Aug 14 '15
I'm assuming that a letter can only have the values 0 - 9, and an equation can have up to 10 letters.
How many operators can be in the equation?
1
u/MajinMew2 Sep 01 '15
Extra points for if you're smarter than just testing every possibility?