Alphametics - Let's discuss input format

Hi colleagues,

Let’s discuss the input format for Alphametics exercise.
The following format is just for debugging purposes.

One solution

gawk -f alphametics.awk -v puzzle="SEND + MORE = MONEY"
Attempting to solve: SEND + MORE = MONEY

Words: SEND, MORE, MONEY
Unique letters (8, sorted): D E M N O R S Y 

Solution #1:
  SEND (9567) + MORE (1085) = MONEY (10652)
  Mapping: D=7 E=5 M=1 N=6 O=0 R=8 S=9 Y=2

Found 1 solution(s).

Several solutions

gawk -f alphametics.awk -v puzzle="TWO + TWO = FOUR"   
Attempting to solve: TWO + TWO = FOUR

Words: TWO, TWO, FOUR
Unique letters (6, sorted): F O R T U W 

Solution #1:
  TWO (734) + TWO (734) = FOUR (1468)
  Mapping: F=1 O=4 R=8 T=7 U=6 W=3

Solution #2:
  TWO (765) + TWO (765) = FOUR (1530)
  Mapping: F=1 O=5 R=0 T=7 U=3 W=6

Solution #3:
  TWO (836) + TWO (836) = FOUR (1672)
  Mapping: F=1 O=6 R=2 T=8 U=7 W=3

Solution #4:
  TWO (846) + TWO (846) = FOUR (1692)
  Mapping: F=1 O=6 R=2 T=8 U=9 W=4

Solution #5:
  TWO (867) + TWO (867) = FOUR (1734)
  Mapping: F=1 O=7 R=4 T=8 U=3 W=6

Solution #6:
  TWO (928) + TWO (928) = FOUR (1856)
  Mapping: F=1 O=8 R=6 T=9 U=5 W=2

Solution #7:
  TWO (938) + TWO (938) = FOUR (1876)
  Mapping: F=1 O=8 R=6 T=9 U=7 W=3

Found 7 solution(s).

I’d use

gawk -f alphametics.awk <<< "SEND + MORE = MONEY"
1 Like

What should the output be? One line

D=7 E=5 M=1 N=6 O=0 R=8 S=9 Y=2

Or line line per letter?

D 7
E 5
M 1
N 6
O 0
R 8
S 9
Y 2
gawk -f alphametics.awk <<< "SEND + MORE = MONEY"

This looks good to me.

Or line line per letter?

I think that’s the simpler (preferred) output.

Yes, I prefer this format.

In canonical data always one solution.

I prefer this format
D=7 E=5 M=1 N=6 O=0 R=8 S=9 Y=2