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.
- Prepare
- Mathematics
- Fundamentals
- Reverse Game
- Discussions
Reverse Game
Reverse Game
Sort by
recency
|
204 Discussions
|
Please Login in order to post a comment
from collections import deque # makes everything easy
if name == 'main': t = int(input().strip()) for _ in range(t): first_multiple_input = input().rstrip().split() n = int(first_multiple_input[0]) k = int(first_multiple_input[1]) d=deque([i for i in range(n)]) l=[] while len(d)>1: l.append(d.pop()) l.append(d.popleft()) if len(d)==1: l.append(d.pop()) print(l.index(k))
Question for you all
Any input would be greatly appreciated. I am wondering why I am getting this answer wrong. I identified the patterns and found that even positions decrease as the series goes on and the odd positions decrease. I built a loop to make make a new string that stores the reversing of the numbers. Then I only look for the index of the string containing k.
When I text it with the example zero it works. I have also done it with other manual examples and it seems to work fine. Not sure why it marks every other example as incorrect ` if name == 'main': t = int(input().strip()) for _ in range(t): # Loop t times first_multiple_input = input().rstrip().split()
Is this broken? The Solution code only brings in the first test case. The T variable tells me there should be 2 cases but only one value for N and K come in. Is there something I need to do to get all the test cases?
Monitoring your Emirates ID status is easy with the UAE government’s online system. You can complete the process from the comfort of your own home, saving time and avoiding hassle. There's no requirement for any special registrations or passwords at https://smarttrekassist.ae/.
!/bin/python3
import math import os import random import re import sys
if name == 'main': t = int(input().strip())