When working on the Connect exercise, I came up with a solution that passes the existing test suite, but then I realized that it would fail test cases for winning paths with “dead ends.” I added the test shown below, and sure enough, my solution failed. What would folks think about adding one or more such test cases?
def test_x_wins_using_a_path_with_a_dead_end(self):
game = ConnectGame(
""". . X .
X X . .
. X X X
O O O O"""
)
winner = game.get_winner()
self.assertEqual(winner, "X")
Thanks for the reminder. I assume that the initial PR would just modify exercises/connect/canonical-data.json? After that, how would the tracks get updated?
The first step would be getting buy-in from at least three maintainers ;)
Then a PR to update the canonical data. Then tracks can sync tests from the canonical data. Exactly how that works is different for each track. Some tracks have auto-generated tests that can be used to regenerate the tests from the canonical data. Other tracks do this by hand.
Tracks can also choose to not use/refuse individual tests from cannonical-data, so just because it is updated doesn’t mean all tracks will use all tests.
I am neutral on the additional tests. You can count me as a +1 if no one else comes out in support in the next day or so.
The additional test cases would require the student to think about how to represent a set of conditions as true only if any of the conditions in the set is true. In Python and other languages, this would be a good use case for the any idiom.