Skip to content

Instantly share code, notes, and snippets.

@selimhamidou
Created July 8, 2020 17:47
Show Gist options
  • Save selimhamidou/597bae80b45d4f931911dd1ae0d2dbce to your computer and use it in GitHub Desktop.
Save selimhamidou/597bae80b45d4f931911dd1ae0d2dbce to your computer and use it in GitHub Desktop.
#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