We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
deffairRations(B):#Get the index of all odd numbersodds=[]foriinrange(N):ifB[i]%2:odds.append(i)length=len(odds)#Will not work if there is an odd number of oddsiflength%2:return"NO"loaves=0#For each pair of odds, you need 2 loaves per distances between themforiinrange(0,length-1,2):loaves+=odds[i+1]-odds[i]returnstr(2*loaves)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Fair Rations
You are viewing a single comment's thread. Return to all comments →
Python 3