Sort by

recency

|

407 Discussions

|

  • + 0 comments

    Null's Brawl APK is a highly popular private server that provides an exciting alternative for Brawl Stars fans. Created by independent developers, this version offers players unlimited resources, unlocked characters, and exclusive content not available in the official game.

  • + 0 comments

    Javascript :

    function counterGame(n) {
        // Write your code here
        let moveCount = 0;
        while (n > 1) {
            if ((n & (n - 1)) === 0) { 
                n = n / 2;
            } else {
                let highestPowerOf2 = 1;
                while (highestPowerOf2 * 2 < n) {
                    highestPowerOf2 *= 2;
                }
                n -= highestPowerOf2;
            }
            moveCount++;
        }
        return moveCount % 2 === 0 ? "Richard" : "Louise";
    }
    
  • + 0 comments

    More at https://github.com/pakbungdesu/hackerrank-problem-solving.git

    Python

    def counterGame(n):
        # initialize the count
        count = 0
    
        # play the game until n becomes 1
        while n > 1:
            # check if n is a power of 2
            if (n & (n - 1)) == 0:
                # if n is a power of 2, divide by 2
                n //= 2
            else:
                # if not, subtract the largest power of 2 less than n
                largest_power = 1 << (n.bit_length() - 1)
                n -= largest_power
            count += 1
        
        return "Louise" if count % 2 else "Richard"
    
  • + 0 comments

    public static String counterGame(long n) { // Write your code here int count=0;

        while(n!=1){
    
        if(((n)&(n-1))==0){
            n=n>>1;
        }
    
    
        else{
            n=n-Long.highestOneBit(n);
    
        }
    
         count++;
    
    }
    if(count%2==0){
        return "Richard";
    }
    return "Louise";
    
    }
    

    }

  • + 0 comments

    " //PANDEY JI

    class Result {

    public static String counterGame(long n) {
    // Write your code here
    int c=0;
    while(n!=1)
    {
        if((n&(n-1))==0)
        {
            n=n>>1;
        }
        else{
            n=n-Long.highestOneBit(n);
        }
        c++;
    }
    if(c%2==0){
       return "Richard";
    }
     return "Louise";
    }"