Created
September 17, 2019 09:10
-
-
Save MatthewWilkes/ff1e430015cbbc5f257f6639f2aec713 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import fractions | |
for num_pads in range(15): | |
options = {num_pads: fractions.Fraction(1)} | |
for pad in range(num_pads-1, 0, -1): | |
free_pads = [p for p in range(num_pads+1) if p > pad] | |
path_lengths = [] | |
for free_pad in free_pads: | |
path_lengths.append(options[free_pad] + 1) | |
options[pad] = sum(path_lengths) / len(path_lengths) | |
print("{} pads: {} hops".format(num_pads, sum(options.values()) / len(options))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment