Skip to content

Instantly share code, notes, and snippets.

@grey-area
Created June 24, 2021 09:31
Show Gist options
  • Save grey-area/62ee1066e4857b522bf8c4cd705b2570 to your computer and use it in GitHub Desktop.
Save grey-area/62ee1066e4857b522bf8c4cd705b2570 to your computer and use it in GitHub Desktop.
def loop(lengths, count=0):
if len(lengths) == 0:
return count + 1
else:
head, *tail = lengths
for _ in range(head):
count = loop(tail, count)
return count
lengths = [2, 3, 8, 6]
count = loop(lengths)
print(count)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment