Created
April 11, 2018 12:03
-
-
Save dashohoxha/064d1a68703192fa0c110934c942747e to your computer and use it in GitHub Desktop.
My solution for this codejam problem: https://codejam.withgoogle.com/2018/challenges/00000000000000cb/dashboard/00000000000079cb
This file contains hidden or 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 troublesort(V): | |
done = False | |
while not done: | |
done = True | |
for i in range(len(V)-2): | |
if V[i] > V[i+2]: | |
done = False | |
V[i], V[i+2] = V[i+2], V[i] | |
def check(V): | |
for i in range(len(V)-1): | |
if V[i] > V[i+1]: | |
return i | |
return 'OK' | |
T = int(input()) | |
for t in range(T): | |
N = int(input()) | |
V = list(map(int, input().split())) | |
troublesort(V) | |
print("Case #{}: {}".format(t+1, check(V))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment