Skip to content

Instantly share code, notes, and snippets.

@aLucaz
Last active March 30, 2023 03:56
Show Gist options
  • Save aLucaz/0a5764c26cfd6bce21c496e9a88fa7a4 to your computer and use it in GitHub Desktop.
Save aLucaz/0a5764c26cfd6bce21c496e9a88fa7a4 to your computer and use it in GitHub Desktop.
def foo(arr):
i = 0
j = len(arr) - 1
while i <= j:
if (arr[i] % 2) != 0:
n = arr.pop(i)
arr.insert(len(arr), n)
else:
n = arr.pop(i)
arr.insert(0, n)
i+=1
if (arr[j] % 2) != 0:
n = arr.pop(j)
arr.insert(len(arr), n)
else:
n = arr.pop(j)
arr.insert(0, n)
j-=1
print(arr)
return arr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment