Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions exercises/alphametics/alphametics_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ def test_puzzle_with_three_letters(self):
self.assertEqual(solve("I + BB == ILL"), {"I": 1, "B": 9, "L": 0})

def test_solution_must_have_unique_value_for_each_letter(self):
self.assertEqual(solve("A == B"), {})
self.assertEqual(solve("A == B"), None)

def test_leading_zero_solution_is_invalid(self):
self.assertEqual(solve("ACA + DD == BD"), {})
self.assertEqual(solve("ACA + DD == BD"), None)

def test_puzzle_with_two_digits_final_carry(self):
self.assertEqual(
Expand Down
6 changes: 3 additions & 3 deletions exercises/alphametics/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ def check_rec(eqparams, tracecombo=(dict(), 0, set(range(10))), p=0):
# if the recursive call returned a non-empty dictionary
# this means the recursion has found a solution
# otherwise, proceed to the new permutation
if len(rectest) > 0:
if rectest and len(rectest) > 0:
return rectest
# if no permutations are avaialble or no
# permutation gave the result return the empty dictionary
return dict()
# permutation gave the result return None
return None


def solve(an):
Expand Down