Skip to content

Instantly share code, notes, and snippets.

@rdisipio
Last active May 21, 2021 15:45
Show Gist options
  • Save rdisipio/d840a74b2e815e26d032280f6e3a6d0f to your computer and use it in GitHub Desktop.
Save rdisipio/d840a74b2e815e26d032280f6e3a6d0f to your computer and use it in GitHub Desktop.
Chessboard exploration
#!/usr/bin/env python
m = 3
n = 4
S = [[None for _ in range(n+1)] for _ in range(m+1)]
for i in range(m):
for j in range(n):
if i==0 or j==0:
S[i][j] = 1
else:
S[i][j] = S[i-1][j] + S[i][j-1]
n_paths = S[m-1][n-1]
print(f"Number of unique paths: {n_paths}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment