For a College Contest hosted on HackerRank
Problem 1 : A Card Game
A Card Game Alice loves to play card games. He was getting bored so he invented a game, that he will arrange all the cards 1 to N in a seqeunce and start removing it one by one alternatively (from odd positions). He will do this until one card is left. Your task is to tell the remaining card. Input Format First line contains the number of test cases t . The next t lines contain integer n, the number of cards for that case. Constraints 1<=T<=1000 1<=N<=10^9 Output Format Single line output, Print the required output. Sample Input 0 2 2 7 Sample Output 0 2 4
The solution I made works on this set but fails in the other one, and is Giving a runtime error.Though The program seems correct , so most probably its because of using 3 loops in python and not doing this question in C or C++.