forked from rahulraghavendhra/HackerRank-Python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jack_and_jill_actual_soln.py
30 lines (29 loc) · 1.19 KB
/
jack_and_jill_actual_soln.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"""
Jack and Jill are two friends. They both are hungry but they have only a few cakes with them. So they started playing a game to grab those cakes. Initially they have N number of cakes with them. Jack starts the game by making the first move. The game is such that in each turn one has to choose a move from a set of moves which consists of all the possible moves for removing p cakes from the table, where p is any prime and k is any nonnegative integer. The winner is the one who takes the last cake. Identify who will win the game, assuming both the players follow a perfect strategy? If Jack wins, what will be the smallest possible number that he can remove in his first move?
Input
An integer T, denoting the number of test cases.
Each test case contains one integer N, the number of chips on the table.
Output
Print "Jack" if Jack wins or "Jill" if Jill wins. Print the output for each test case on a
new line (without quotes).
Constraints
1 <= T <= 100000
1 <= N <= 100000
Sample Input :
3
1
5
6
Sample Output:
Jack 1
Jack 5
Jill
"""
n = input()
for test in xrange(0,n):
num_cakes = input()
rem = num_cakes % 6
if rem == 0:
print("Jill")
else:
print("Jack "+str(rem))