Temperatures puzzle discussion


#780

I checked your code…
I just modified to take the input from CG and added a console.log to print the output
and it works for the tests (did not check validators)


#781
import sys
import math

# Auto-generated code below aims at helping you parse
# the standard input according to the problem statement.

n = int(input())# the number of temperatures to analyse
x = 0
tpos = []
tneg = []
mmm = False
nnn = False

for i in input().split():
    # t: a temperature expressed as an integer ranging from -273 to 5526
    t = int(i)
    if x < t :
        tpos = [t]
    elif x > t :
        tneg = [t]

if len(tpos) > 0 :
    m = min(tpos)
    mmm = True
elif len(tpos) == 0 : 
    mmm = False

if len(tneg) > 0 :
    n = max(tneg)
    nnn = True
elif len(tneg) == 0 :
    nnn = False

if nnn == True and mmm == True :
    mm = m*m
    nn = n*n
    if nn > mm :
        result = m
    elif mm > nn :
        result = n
    elif mm == nn : 
        result = m        
if nnn == True and mmm == False :
    result = max(tneg)

if nnn == False and mmm == True :
    result = min(tmax)
    
if nnn == False and mmm == False :
    result = 0
# Write an action using print
print("Debug messages...", file=sys.stderr)

print(result)

Please help i can’t find problem in code (it is in python 3)


#782

Insert after the first “for”

print(tpos,file=sys.stderr)
print(tneg,file=sys.stderr)

After i think that you’ll easily find where is the problem … :wink: