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.
defcounterGame(n):# initialize the countcount=0# play the game until n becomes 1whilen>1:# check if n is a power of 2if(n&(n-1))==0:# if n is a power of 2, divide by 2n//= 2else:# if not, subtract the largest power of 2 less than nlargest_power=1<<(n.bit_length()-1)n-=largest_powercount+=1return"Louise"ifcount%2else"Richard"
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Counter game
You are viewing a single comment's thread. Return to all comments →
More at https://github.com/pakbungdesu/hackerrank-problem-solving.git
Python