Skip to content

Instantly share code, notes, and snippets.

@nsomar
Created July 16, 2015 08:16
Show Gist options
  • Save nsomar/8b5d14a79f56e551542d to your computer and use it in GitHub Desktop.
Save nsomar/8b5d14a79f56e551542d to your computer and use it in GitHub Desktop.
import Queue
a = [1, [2], [3], [4,5]]
q = Queue.Queue()
res = []
def copy_arr_to_q(arr, q):
for item in arr:
q.put(item)
copy_arr_to_q(a, q)
while not q.empty():
element = q.get()
if type(element) is list:
copy_arr_to_q(element, q)
else:
res.append(element)
print(res)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment