×

# RAINBOWA python code wrong output

here is my python code:

q="1234567"

k=[]

# function to omit test cases like 2 1 3 4 5 6 7 6 5 4 3 1 2

def is_increasing(n):

for i in range(int(len(n)/2)):

if n[i]>n[i+1]:

return False

return True


# function to check given array a rainbow array

def is_rainbow(n):

for i in range(len(n)):

if n[i]==n[len(n)-i-1] and str(n[i]) in q and is_increasing(n):

continue

else:

return False

return True


x=int(input())

for i in range(x):

s1=int(input())

s=list(map(int,input().split()))

if (is_rainbow(s)):

k.append(1)

else:

k.append(0)


for l in k:

if l==1:

print("yes")

else:

print("no")


can you please tell me whats wrong in my code.

11
accept rate: 0%

 0 Where are you calling the "is increasing" function? Also, what if your array is like 1 2 3 4 5 6 7 8 7 6 5 4 3 2 1 Above is not a rainbow array as it has an element more than 7, i.e. 8. answered 09 Sep '17, 14:58 15.2k●1●18●59 accept rate: 18%
 0 Yep, @vijju123 is right. answered 09 Sep '17, 19:23 11●2 accept rate: 0%
 0 Here is my solution in python ! what i essentially did was checked for palindrome and increment the checking factor by one starting with zero and also note the middle element has to be 7 and rest all cases are false answered 09 Sep '17, 23:35 94●4 accept rate: 0%
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×846
×262
×41

question asked: 09 Sep '17, 14:22

question was seen: 429 times

last updated: 09 Sep '17, 23:35