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.
  • Practice
  • Certification
  • Compete
  • Career Fair
  • Hiring developers?
  1. Practice
  2. Algorithms
  3. Bit Manipulation
  4. Counter game

Counter game

Problem
Submissions
Leaderboard
Discussions
Editorial

Louise and Richard have developed a numbers game. They pick a number and check to see if it is a power of . If it is, they divide it by . If not, they reduce it by the next lower number which is a power of . Whoever reduces the number to wins the game. Louise always starts.

Given an initial value, determine who wins the game.

As an example, let the initial value . It's Louise's turn so she first determines that is not a power of . The next lower power of is , so she subtracts that from and passes to Richard. is a power of , so Richard divides it by and passes to Louise. Likewise, is a power so she divides it by and reaches . She wins the game.

Update If they initially set counter to , Richard wins. Louise cannot make a move so she loses.

Function Description

Complete the counterGame function in the editor below. It should return the winner's name, either Richard or Louise.

counterGame has the following parameter(s):

  • n: an integer to initialize the game counter

Input Format

The first line contains an integer , the number of testcases.
Each of the next lines contains an integer , the initial value for the game.

Constraints

Output Format

For each test case, print the winner's name on a new line in the form Louise or Richard.

Sample Input 0

1
6

Sample Output 0

Richard

Explanation 0

  • is not a power of so Louise reduces it by the largest power of less than :.
  • is a power of so Richard divides by to get and wins the game.

Author

dheeraj

Difficulty

Medium

Max Score

30

Submitted By

36798

Need Help?


View discussions
View editorial
View top submissions

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits

Choose a translation


  • Contest Calendar
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature