Can one tell me why is this a wrong answer ? or where I might find test cases that would fail for the below code?
# cook your dish here
for tc in range(int(input())):
num_elements = int(input())
values = list(range(1,8))
rainbow = list(map(int,input().split(' ')))
for value in rainbow:
if value in values:
all_colors = True
else:
all_colors = False
print('no')
break
if all_colors:
for i in range(0,len(rainbow)//2+1):
if rainbow[i] == rainbow[-i-1]:
rbow = True
else:
rbow = False
break
if rbow == True:
print('yes')
else:
print('no')
Actually I tweaked the code, works for test cases as far as I can go. But still I do not get an AC:
Worst part is all solutions look the same. I will just check 20-30 solutions to this lame problem when I find time. Maybe I will know what I am missing.
# cook your dish here
for tc in range(int(input())):
num_elements = int(input())
values = list(range(1,8))
rainbow = list(map(int,input().split(' ')))
for value in rainbow:
if value in values:
all_colors = True
else:
all_colors = False
print('no')
break
if all_colors:
for i in range(0,len(rainbow)//2+1):
if rainbow[i] == rainbow[-i-1]==7 and i - len(rainbow)//2 != 0:
rbow = False
break
elif rainbow[i] == rainbow[-i-1]:
rbow = True
else:
rbow = False
break
if rbow == True:
print('yes')
else:
print('no')
PS : You have saved me a couple of time, I should have sent you a bouquet.
After removing adjacent duplicates (i.e. collapsing runs of the same number into a single instance of that number), the remainder is exactly the list 1,2,3,4,5,6,7,6,5,4,3,2,1.
I mean yeah! I can try to do it a different way and it should work. But what irks me is the ambiguity of the solution. I get very itchy if I see something like that.