Refuse a returned list that reaches a node twice

Merged
HE
2d ago
+140-5

Every list serializer stopped at the first revisited node, so a returned list whose tail points back into itself printed as the acyclic list it loops over and the exact checker accepted it. The C++ toJson(ListNode*), Java json(ListNode), JavaScript listToArray and Python _list_to_array now refuse the revisit with "Returned list must not reach a node twice.", matching the tree wording in #388, and C's json_list detects the cycle instead of printing 10000 values. The new C, C++ and Java toolchain cases and the runner source check fail before this change.

Closes #375


Summary by cubic

Rejects cyclic linked lists returned by solutions so a tail pointing back into itself no longer prints as the acyclic list it loops over and passes the exact checker.

  • C, C++, Java, JavaScript, and Python list serializers now raise "Returned list must not reach a node twice." instead of silently truncating at the first revisited node; C's json_list detects the cycle via Floyd's algorithm instead of capping output at 10000 values.
  • Adds browser tests covering the C, C++, and Java harnesses and a source-level check for the JavaScript and Python runners.

Closes #375.