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.
#!/bin/python3importmathimportosimportrandomimportreimportsys## Complete the 'counterGame' function below.## The function is expected to return a STRING.# The function accepts LONG_INTEGER n as parameter.#defcounterGame(n):# Write your code hereturns=0whilen>1:power=1<<(n.bit_length()-1)ifn==power:n>>=1else:n-=powerturns+=1return"Louise"ifturns%2!=0else"Richard"if__name__=='__main__':fptr=open(os.environ['OUTPUT_PATH'],'w')t=int(input().strip())fort_itrinrange(t):n=int(input().strip())result=counterGame(n)fptr.write(result+'\n')fptr.close()
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 →
Python 3 Solution: