Skip to content

Instantly share code, notes, and snippets.

@YDrall
Last active February 11, 2020 08:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YDrall/f1bf6f15be54063f9d2ffdadbf19495b to your computer and use it in GitHub Desktop.
Save YDrall/f1bf6f15be54063f9d2ffdadbf19495b to your computer and use it in GitHub Desktop.
arr = [1, 2, 3, 4]
from collections import deque
qu = deque([[a] for a in range(len(arr))])
while qu:
q = qu.popleft()
print([arr[i] for i in q])
for j in range(q[-1]+1, len(arr)):
qu.append(q + [j])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment