bilingual-math-code-verification-v1 / code /math_code_007_solution.py
efe-T's picture
Upload folder using huggingface_hub
93237a0 verified
Raw History Blame Contribute Delete
444 Bytes
blocked = {(1, 1), (2, 3)}
dp = [[0] * 5 for _ in range(5)]
for x in range(5):
for y in range(5):
if (x, y) in blocked:
continue
if (x, y) == (0, 0):
dp[x][y] = 1
else:
dp[x][y] = (dp[x-1][y] if x else 0) + (dp[x][y-1] if y else 0)
assert dp[1][1] == 0 and dp[2][3] == 0
result = {"valid_paths": dp[4][4]}
import json
print(json.dumps(result, ensure_ascii=False, sort_keys=True))