Add more detailed error messages for the RB assignment

This commit is contained in:
2026-07-21 20:13:27 -04:00
parent d488ac5575
commit 059c848d3d

View File

@@ -1,3 +1,5 @@
import traceback
class Node: class Node:
def __init__(self, value, left=None, right=None, parent=None, is_red=False): def __init__(self, value, left=None, right=None, parent=None, is_red=False):
self.value = value self.value = value
@@ -451,8 +453,10 @@ def run_tests():
print(" Your rebalance likely created a cycle or otherwise broke the") print(" Your rebalance likely created a cycle or otherwise broke the")
print(" tree structure (a child pointing back up at an ancestor).\n") print(" tree structure (a child pointing back up at an ancestor).\n")
continue continue
except Exception as e: except Exception:
print(f" RESULT: ERROR - {type(e).__name__}: {e}\n") print(f" RESULT: ERROR - see stack trace below\n")
print(traceback.format_exc())
print("")
continue continue
# Guard the author (you) against a typo when adding a new case: the # Guard the author (you) against a typo when adding a new case: the