Editorial : Replace X , Posand

Editorial of Codechef September long challenge 2020 Video Editorial|video solution
Beginer friendly Editorial

  1. Replace for X : REPLESX
    https://youtu.be/wRKnRo-prBo

  2. Positive AND : POSAND
    https://youtu.be/UzQYBfmVkEg

  3. Chef and Easy Queries : CHEFEZQ
    https://youtu.be/8-OD0HN7Tvc

  4. Covid Run : CVDRUN
    https://youtu.be/gTkxj8wMba0

Please Share our videos with your class group and Friends and help our community to grow

" Dont Stop chassing your Dreams "

For POSAND, my solution is exactly the same but it gives wrong answer for task#3. Posting the solution below. Please help with whats wrong:

I even tried to simulate the entire sample set for errors, couldn’t find any. (commented code at the end)

# cook your dish here
import math
 
# Function to check
# if x is power of 2
def isPowerOfTwo(n):
    return (math.ceil(math.log2(n)) ==
            math.floor(math.log2(n)));

seq = [i for i in range(1,100000)]
seq[0] = 2
seq[1] = 3
seq[2] = 1
for i in seq:
    if i <= 3:
        pass
    elif isPowerOfTwo(i-1):
        seq[i-1] = i-1
        seq[i-2] = i
            
t = int(input())
while t>0:
    t=t-1
    n=int(input())
    if n==1:
        print('1')
    elif n==3:
        print('1 3 2')
    elif isPowerOfTwo(n):
        print(-1)
    else:
        print(' '.join([str(i) for i in seq[0:n]]))

        # for i in range(1,n+1):
        #     if(i == 1):
        #         pass
        #     else:
        #         if(seq[i-1] & seq[i-2] == 0):
        #             print('anomaly' + str(seq[i-1]) + ':' + str(seq[i-2]) + 'for n=' + str(i))

before checking for 2 power first check for n==1 then print 1 then you will get ac because on 1 now your code is giving -1

N=1 shouldn’t lie in the constraints of the problem. This has to be corrected. N should be atleast 2, for the problem to make sense.

I am checking for n == 1 at the beginning. The checks are if n == 1, else if n ==3, else if n is a power of 2. Like that. There is something wrong which I am not able to find out.