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.
functioncounterGame(n:number):string{letturn=true// Write your code hereconstisPowerOfTwo=(num:number):{isPower:boolean,lowerPower:number}=>{letcalc=1letpower=0while(calc<num){power+=1calc*=2}if(calc==num){return{isPower:true,lowerPower:0}}else{return{isPower:false,lowerPower:calc/2}}}while(n!=1){constisPowtwo=isPowerOfTwo(n)if(isPowtwo.isPower){n=n/2}else{n-=isPowtwo.lowerPower}turn=!turn}returnturn?'Richard':'Louise';}
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 →
Typescript solution