I have almost coded for the program still the sec Testcase confusing me .
At a certain laboratory results of secret research are thoroughly encrypted. A result of a single experiment is stored as an information of its completion: ‘positive result’, ‘negative result’, ‘experiment failed’ or ‘experiment not completed’ The encrypted result constitutes a string of digits S , which may take one of the following forms:
positive result S = 1 or S = 4 or S = 78
negative result S = S 35
experiment failed S = 9 S 4
experiment not completed S = 190 S
(A sample result S35 means that if we add digits 35 from the right hand side to a digit sequencethen we shall get the digit sequence corresponding to a failed experiment) You are to write a program which decrypts given sequences of digits.
Input :
A integer n stating the number of encrypted results and then consecutive n lines, each containing a sequence of digits given as ASCII strings.
Output :
For each analysed sequence of digits the following lines should be sent to output (in separate lines):
+ for a positive result
- for a negative result
* for a failed experiment
? for a not completed experiment
In case the analysed string does not determine the experiment result, a first match from the above list should be outputted.
Sample Testcase :
INPUT
4
78 7835 19078 944
OUTPUT
+
-
?
*
My code:
n=int(input())
value_list=list(map(str,input().split()))
a=1
for i in value_list:
if (i=='1' or i=='4' or i=='78'):
print('+')
if a==1:
a='+'
elif (i[len(i)-2:len(i)]=='35'):
s=i[::-1]
s=s[2:]
s=s[::-1]
if (s=='1' or s=='4' or s=='78'):
print('-')
if a==1:
a='-'
elif(i[0]=='9' and i[-1]=='4'):
s=i[1:len(i)-1]
if (s=='1' or s=='4' or s=='78'):
print('*')
if a==1:
a='*'
elif(i[:3]=='190'):
s=i[3:]
if (s=='1' or s=='4' or s=='78'):
print('?')
if a==1:
a='?'
else:
print(a)
I'm confused in the sec testcase in this problem . please help me to get the sec testcase idea╯︿╰.