You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: Handle integer output parsing in JUDGE_FUNC for 7 solutions
The test framework uses ast.literal_eval() to parse solution outputs,
which converts single numbers like "1" to integers. The judge functions
in 7 solutions were only checking for str or list types, causing test
failures when outputs were parsed as integers.
Fixed solutions:
- 0021_merge_two_sorted_lists: Handle int input + fix empty line parsing
- 0027_remove_element: Handle int input for k=0 single-line output case
- 0075_sort_colors: Handle int input for single-element arrays
- 0088_merge_sorted_array: Handle int input + fix empty array parsing
- 0283_move_zeroes: Handle int input for single-element arrays
- 0876_middle_of_the_linked_list: Handle int input for single-node lists
- 0905_sort_array_by_parity: Handle int input for single-element arrays
Changes:
- Added isinstance(actual, int) checks in all judge functions
- Convert single integers to single-element lists: [actual]
- Improved input parsing to preserve empty lines correctly
- No changes to solution algorithms (all were already correct)
Test Results:
- All 92 tests pass (7 skipped for problems without static tests)
- Static tests: 33/33 passing
- Generated tests: 59/59 passing
- Combined tests: 99/99 passing
Root Cause:
The compare.py module uses ast.literal_eval() to parse outputs before
passing to JUDGE_FUNC. Single numbers get parsed as int, not str,
which the judge functions didn't handle.
0 commit comments