RAINBOWA [Practice & Learn (Beginner)]

The problem statement is INCOMPLETE OR the test cases are WRONG because when I give the input = 1 2 3 4 5 6 -9 7 -9 6 5 4 3 2 1, it should give the output = “no”. But when a THREE STAR coder(unnatirusia) wrote his code in PYTHON and when I used the above input, the output given by “unnatirusia” was “yes”. I want to know whether my input should give output as “no” or “yes”. If I have misunderstood the question, then please, can you help me with this ? You can run THREE STAR coder’s (unnatirusia) code by copying the code from CodeChef: Practical coding for everyone

{{ I have spend FOUR hours on this problem statement and my solution was always WRONG. Then I decided to copy code from other coders and thats how I landed here, posting a comment }}

Correct Solution according to me :-
(If you want my code with PROPER INDENTATION, then visit :- CodeChef: Practical coding for everyone)

for i in range(int(input())):
flag1, flag2, count3, flag3 = 0, 0, 7, 0
n = int(input())
list1 = list(map(int, input().split()))
for k in list1:
if k <= 0 or k > 7:
print(“no”)
flag1 = 1
break
if flag1 == 0:
if n % 2 == 1 and n >= 13 and list1[n // 2] == 7 and list1[0] == 1 and list1[n - 1] == 1:
for j in range(1, (n // 2) + 1):
if list1[(n // 2) + j] != list1[(n // 2) - j]:
print(“no”)
flag2 = 1
break
else:
if list1[(n // 2) + j] == count3:
continue
elif list1[(n // 2) + j] == (count3 - 1):
count3 -= 1
else:
print(“no”)
flag3 = 1
break
if flag2 == 0 and flag3 == 0:
print(“yes”)
else:
print(“no”)

(If my solution is not passing any specific test case, then please comment it.)

1 Like

The output for the test input:

1
15
1 2 3 4 5 6 -9 7 -9 6 5 4 3 2 1

should be:

no

The testcases for this problem are weak.

1 Like

Thankyou so much. I really appreciate your response.

1 Like

Your solution is also wrong, and fails for the test input:

1
15
1 2 3 4 5 6 7 8 7 6 5 4 3 2 1

2 Likes

Ya. Thats why I was searching for the correct answer.
Thanks once again.

1 Like