Temperatures puzzle discussion


The issue is that input() read the line …
num = int(input()) => num = int('1 -2 -8 4 5')
It is not correct …

What you can do is getting the values as string
nums = input().split()
then you can loop to use these but the base code generated by CG already do this for you :
for i in input().split():

No need to reinvent the wheel :wink:


I don’t understand why on Javascript I failed this…

Two negative temperatures that are equal: {-10 -10}

Yet passed everything else with a 90%. Not sure how to ask for help since I can’t post code. Yes I understand that the answer itself is -10. What I don’t understand is

} else if (Math.abs(t) === Math.abs(x)) {
    x = Math.abs(t);

Fails that?


If you use x as an answer, it will always be positive.
Your test works for {10 10} or {-10 10}, not for {-10 -10}.


(post withdrawn by author, will be automatically deleted in 24 hours unless flagged)