Created
October 7, 2018 04:03
-
-
Save alexgolec/50d120cac9c419dfecfe077d040ff5a5 to your computer and use it in GitHub Desktop.
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
def count_sequences(start_position, num_hops): | |
prior_case = [1] * 10 | |
current_case = [0] * 10 | |
current_num_hops = 1 | |
while current_num_hops <= num_hops: | |
current_case = [0] * 10 | |
current_num_hops += 1 | |
for position in range(0, 10): | |
for neighbor in neighbors(position): | |
current_case[position] += prior_case[neighbor] | |
prior_case = current_case | |
return current_case[start_position] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Transcribed to Javascript for those interested