Last active
December 3, 2017 02:03
-
-
Save sakekasi/a07eaee1041b0ae71f766f76195a85d1 to your computer and use it in GitHub Desktop.
mystery 2
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 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