my
$ex04_lungty
= [
"A+B+B=AB"
];
my
$ex52_lungty
= [
"ABCAB*A=DDDDDD"
];
my
$first_property_two_and_four
= [
"A**B = B**A"
];
my
$second_property_two_and_four
= [
"A+A = A*A"
];
my
$use_of_property_of_nine
= [
"A * D = BC"
,
"B + C = 9"
,
"A % 4 = 0"
];
my
$pythagorean_triple1
= [
"A * A + B * B = C * C"
];
my
$pythagorean_triple2
= [
"A * A + BC * BC = 169"
];
my
$symmetry
= [
"AAAAA * AAAAA = ABCDEDCBA"
];
cmp_deeply(
Math::Cryptarithm->new(
$ex04_lungty
)->solve_ans_in_equations(),
[ [
"1+9+9=19"
] ],
"Exercise 04 from Lung's article"
);
cmp_deeply(
Math::Cryptarithm->new(
$ex52_lungty
)->solve_ans_in_equations(),
[ [
"37037*3=111111"
] ],
"Exercise 52 from Lung's article"
);
cmp_set(
Math::Cryptarithm->new(
$first_property_two_and_four
)->solve_alphabetvalue_hash(),
[ {
"A"
=>2,
"B"
=>4 }, {
"A"
=>4,
"B"
=>2 } ],
"Well-known property of 2 and 4"
);
cmp_set(
Math::Cryptarithm->new(
$second_property_two_and_four
)->solve_alphabetvalue_hash(),
[ {
"A"
=>2}, {
"A"
=>0} ],
"Well-known property of 0, 2 and 4"
);
cmp_set(
Math::Cryptarithm->new(
$use_of_property_of_nine
)->solve_alphabetvalue_hash(),
[
{
"A"
=> 4,
"B"
=> 3,
"C"
=> 6,
"D"
=> 9},
{
"A"
=> 8,
"B"
=> 7,
"C"
=> 2,
"D"
=> 9}
],
"Made use of well-known property of 9's multiples"
);
cmp_set(
Math::Cryptarithm->new(
$pythagorean_triple1
)->solve_alphabetvalue_hash(),
[
{
"A"
=> 3,
"B"
=> 4,
"C"
=> 5},
{
"A"
=> 4,
"B"
=> 3,
"C"
=> 5}
],
"Pythagorean triple I"
);
cmp_set(
Math::Cryptarithm->new(
$pythagorean_triple2
)->solve_alphabetvalue_hash(),
[
{
"A"
=> 5,
"B"
=> 1,
"C"
=> 2 },
{
"A"
=> 0,
"B"
=> 1,
"C"
=> 3 }
],
"Pythagorean triple II"
);
cmp_set(
Math::Cryptarithm->new(
$symmetry
)->solve_alphabetvalue_hash(),
[
{
"A"
=> 1,
"B"
=> 2,
"C"
=> 3,
"D"
=> 4,
"E"
=> 5}
],
"11..11 ** 2 = 123..321"
);
done_testing();