Created
July 8, 2020 17:47
-
-
Save selimhamidou/597bae80b45d4f931911dd1ae0d2dbce to your computer and use it in GitHub Desktop.
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
#https://www.hackerrank.com/challenges/new-year-chaos/problem | |
def minimumBribes(q): | |
count=0 | |
q=[p-1 for p in q] | |
for i in reversed(q): | |
ind=q.index(i) | |
if ind>i: | |
temp=ind-i | |
print(temp) | |
if temp>2: | |
return("Too chaotic") | |
else: | |
count=count+temp | |
return count | |
q=[2,5,1,3,4] #Marche pour q=[2,1,5,3,4] mais pas pour [2,5,1,3,4] | |
print(minimumBribes(q)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment