Skip to content

Instantly share code, notes, and snippets.

@sakekasi
Last active December 3, 2017 02:03
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 sakekasi/a07eaee1041b0ae71f766f76195a85d1 to your computer and use it in GitHub Desktop.
Save sakekasi/a07eaee1041b0ae71f766f76195a85d1 to your computer and use it in GitHub Desktop.
mystery 2
def mystery2(lst, n):
if n == 0:
return lst
elif lst == []:
return lst
else:
a = mystery2(lst[1:], n-1)
b = a[0:n-1]
c = a[n-1:]
return b + [lst[0]] + c
ans = mystery2([1,3,4,7,9], 3)
# 3. What does mystery([1,3,4,7,9], 3) return?
# 4. How many times is mystery2 called during
# the execution of mystery2([1,3,4,7,9], 3),
# including the first call to mystery2?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment