"I want to ask a question" - Ask them all here!

i was trying the question of rainbow array in beginner’s section and here’s my code:-
try:
t=int(input())

li=[1,2,3,4,5,6,7,8,9,10]
l=[];y=''
is_this_true=True
for i in range(t):
    le=int(input())
    l+=map(int,input().split())
    cnt=l.count(7)
    mid =le//2
    for k in l:
        if k not in li:
            is_this_true=False
            break
    for j in range(mid):
        if (l[mid-j]==l[mid+j]) and (l[j]+1==l[j+1] or l[j]==l[j+1]) and (is_this_true) and l[mid]==7 and cnt%2!=0:
            y="yes"
        else:
            y="no"
            break
    print(y)
    l=[]

except:
pass
i don’t know what is wrong with this code.Please help!!

Consider the test input in this post.

i tried the suggested input in following code:-
t=int(input())
li=[1,2,3,4,5,6,7]
y=’’;l=[]

is_this_true=True
for i in range(t):
le=int(input())
l+=(map(int,input().split()))
mid =le//2
for k in li:
if k not in l:
is_this_true=False
break
for j in range(mid):
if (l[mid-j]==l[mid+j]) and (l[j]+1==l[j+1] or l[j]==l[j+1]) and (is_this_true) and l[mid]==7:
y=“yes”
else:
y=“no”
break
print(y)
l=[]
is the answer “no” for this input??

The expected output for the test input:

1
13
2 2 3 4 5 6 7 6 5 4 3 2 2

is indeed no - otherwise, what would a_1 be?

i am also getting “no”, but my code is still wrong…

Please either format your new code or (better!) link to your submission - the forum software has mangled it and it won’t compile! :slight_smile:

https://www.codechef.com/viewsolution/56591491

1 Like

Consider the test input:

3
14
1 2 3 4 5 6 7 6 5 4 3 2 1 1
13
1 2 3 4 5 6 8 6 5 4 3 2 1
19
1 2 3 4 4 5 6 6 6 7 6 6 6 5 4 4 3 2 1

thanks, i understood my mistake.

1 Like

this is a partially correct answer, I am not getting the cases that might give error…please suggest some cases that might go wrong in this code of " chef and pairs"
https://www.codechef.com/viewsolution/56786343

i am getting this code wrong but i am getting all the given results correctly…please point out the mistake…!!
https://www.codechef.com/viewsolution/57409941

Your solution gives the wrong output for the test input:

1
aabbcccddddd

Is the answer Dynamic as 2+3=5???(2a ,3c and 5d)

No, it’s not Dynamic.

What permutation C have you chosen?

Means? I did not understand the question…

Can you please explain how it is Not dynamic??

i wrote this code for problem chef and proxy, it is working alright for me but it is showing that answer is not correct , please point out the mistake!!!
https://www.codechef.com/viewsolution/58536954

hii,im new to competitive programming and when im trying this particular program i was getting my desired output but it shows partially correct can you please look into it and guide me : CodeChef: Practical coding for everyone