Light Mode
Dark Mode
Bug in check_solution

This was a great mission. I found a bug in `check_solution` (line 45 in initial code), the last comparison clearly should be `n_col >= max_col`.

if 0 > n_row or n_row >= max_row or 0 > n_col or n_row >= max_col:

Although I suggest to flip the order and do the much more readable and error proof:

if not 0 <= n_row < max_row or not 0 <= n_col < max_col:

This wasn't triggered for the standard examples because many are square, or at least not higher than wide. To recreate the problem use the following and maybe add it as a test.

assert check_solution(checkio, 11, list('SB....BE'))
Created: Oct. 7, 2022, 11:31 p.m.
Updated: Oct. 10, 2022, 9:51 p.m.
0
38
User avatar
juestr