Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Two Friends

By Alim14 · Limits 1s, 512 MB

CodeMask and CodeNewtons are two friends. Today they are playing an interesting game.

The game involves a basket with N balls in it. In each turn one removes some balls from it. In the first turn one must remove at least one ball but not all of the balls. In the subsequent turns, one can remove any number of balls from the basket. If CodeMask removes an even number of balls then CodeNewtons must remove an odd-number of balls, and vice-versa.

The winner is who plays the last turn and makes the basket empty. The game ends in a tie when it is impossible to make the basket empty.

Assume both players play optimally. Here optimally means a player wants to play in such a way so that the opponent player does not win.

CodeMask always makes the first move.


The input starts with an integer T (T ≤ 100), denoting the number of test cases.

Each case contains an integer N (1 ≤ N ≤ 1000) indicating the number of balls in the basket at the start of the game.


For each case, print the case number as "Case X:" followed by “CodeMask” if CodeMask wins, “CodeNewtons” if CodeNewtons win, or “Tie” in case of game ends in a tie.


Case 1: CodeNewtons
Case 2: CodeMask

This problem was authored for CodeMask Championship 2016 and is being hosted on Toph per organizer’s request.



85% Solution Ratio

dip_BRUREarliest, Dec '17

rubbyEFastest, 0.0s

A1701052Lightest, 0 B

bokaifShortest, 120B


Login to submit