Add test cases
All checks were successful
Deploy to birb co. production / deploy (push) Successful in 9s

This commit is contained in:
2026-04-09 10:01:27 -07:00
parent 82ff1c82b0
commit cea3fba36f

View File

@@ -12,3 +12,26 @@
# Start with the "innermost" expression and work backwards (this is the recursion part) # Start with the "innermost" expression and work backwards (this is the recursion part)
# #
# For help, email me@bchen.dev # For help, email me@bchen.dev
# Use this function definition:
def rpn(expression: list[str]) -> int:
return 0
# The following test cases should pass (please copy this into your code):
tests = [
(["3", "2", "+"], 5),
(["3", "4", "*"], 12),
(["3", "4", "2", "+", "*"], 18),
([], 0),
(["50", "2", "/"], 25),
(["5", "2", "/"], 2), # for division, cast to int using int(num)
(["5", "4", "3", "-", "*"], 5),
]
for case in tests:
result = rpn(case[0])
expected = case[1]
if result == expected:
print(f"PASS: expected {expected}, got {result} for {case[0]}")
else:
print(f"FAIL: expected {expected}, got {result} for {case[0]}")