Created
July 20, 2021 01:04
-
-
Save jbrzozoski/d91db2529d7d81237b70a32c7dd3db5c to your computer and use it in GitHub Desktop.
Bead Maze
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from functools import lru_cache | |
@lru_cache(maxsize=1024) | |
def combinations(beads, low_points): | |
if low_points == 1: | |
return 1 | |
return sum(combinations(n, (low_points - 1)) for n in range(0, (beads + 1))) | |
print('Blue - 7 beads, 3 lows = {}'.format(combinations(7, 3))) | |
print('Red - 8 beads, 5 lows = {}'.format(combinations(8, 5))) | |
print('Green - 6 beads, 3 lows = {}'.format(combinations(6, 3))) | |
print('Abacus - 10 beads, 2 lows = {}'.format(combinations(10, 2))) | |
print('Abacus - 10 beads, 3 lows = {}'.format(combinations(10, 3))) | |
print('Abacus - 10 beads, 4 lows = {}'.format(combinations(10, 4))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment