No testing for Alphametrics in Python

I was rather surprised that no tests were run for the Alphametrics exercise. I went through a lot of trouble to try to optimize my solution for time, and I was rather disappointed when I saw that no tests were run. I was curious of how it would run on the server since all tests (including the extra credit one) ran in a little over 2 seconds on my Windows 11 PC running in WSL2:

$ pytest -vvl
...
=== 10 passed in 2.05s ===

$ pytest -vvl --durations 20 | grep call
1.47s call     alphametics/alphametics_test.py::AlphameticsTest::test_puzzle_with_ten_letters
0.23s call     alphametics/alphametics_test.py::AlphameticsTest::test_puzzle_with_eight_letters
0.22s call     alphametics/alphametics_test.py::AlphameticsTest::test_puzzle_with_seven_letters
0.05s call     alphametics/alphametics_test.py::AlphameticsTest::test_puzzle_with_ten_letters_and_199_addends
0.01s call     alphametics/alphametics_test.py::AlphameticsTest::test_puzzle_with_six_letters
0.00s call     alphametics/alphametics_test.py::AlphameticsTest::test_leading_zero_solution_is_invalid
0.00s call     alphametics/alphametics_test.py::AlphameticsTest::test_puzzle_with_four_letters
0.00s call     alphametics/alphametics_test.py::AlphameticsTest::test_puzzle_with_three_letters
0.00s call     alphametics/alphametics_test.py::AlphameticsTest::test_puzzle_with_two_digits_final_carry
0.00s call     alphametics/alphametics_test.py::AlphameticsTest::test_solution_must_have_unique_value_for_each_letter

IIRC, we disabled the editor and online tests for this exercise shortly after we launched the V3 website because they regularly timed out for most students. It became problematic to explain over and over why the tests weren’t “broken” - they were super-duper slow.

We figured that with 140+ other exercises, motivated students could download the exercise and run the tests, and those who wanted to only use the online editor could skip the exercise without missing out significantly.

I can put this exercise on the list to re-examine after the other maintenance work and bug fixes we have scheduled, but we may not be able to annotate it well enough to enable it online.

2 Likes