In one site there was one practice question which ask you to make one program:
Tapas and Meghana are appointed as the one responsible for interviews of AXIS Core committee '17 ! In order to decide upon the order in which to call the aspirants for the interview, they have come up with a brilliant game. It goes like: the core game is divided into \$N\$ phases; and \$N\$ aspirants, successively numbered from \$1\$ to \$N\$, are moving round a circle one after another, i.e. the first follows the second, the second follows the third, ..., the \$(N-1)\$th follows the \$N\$th, and the \$N\$th follows the first. At each phase, a single aspirant is made to leave the circle and is taken up for interview. While the others continue to move. At some phase, the circle is left by an aspirant, who is marching \$K\$ positions before the one, who left the circle at the previous phase. An aspirant, whose number is \$K\$, leaves the circle at the first phase.
Input The only line contains the integer numbers \$N\$, and \$K\$.
Output You should output the order in which in the aspirants give their interviews. The numbers should be separated by single spaces.
Constraints \$1\le N\le 100000\$; \$1\le K\le N\$.
According to my understanding this question is related to queue.
a,b = raw_input().split() a = int(a) b = int(b) c =  d =  for i in range(a, 0, -1): c.append(i) while len(c) != 0: for i in range(1, b): f = c.pop() c.insert(0, f) print c.pop(),
This code was working fine but on some input cases it was showing time limit exceed. So I was wondering that if there is any algorithm which can work better than this or is there any problem with my code which I don't know ?