Temperatures puzzle discussion


You complicate too much just append them to one array and do one pass of the values with checking for value. You have constrains for the input just init to value like 10000.

result = cur = 10000
for c in tmp:
    if abs(c) < cur:
        cur = abs(c)
        result = c


wait, what?



Yeap sorry didn’t read that.


I have exactly the same problem with this.
Maybe it’s a bug so we can’t pass this test :slight_smile:

Edit: I’ve just figured it out after I replied to you XD


This is the moment where I realize how handy C# is when you are coming from C++.
There is no need to worry about the case if there are no values delivered because a int is 0 per default. Not so in C++…


Bonjour, je débute sur codingame, et je ne comprends pas le message d’erreur :
voici mon code, si une bonne âme passe da


Bonjour, je débute sur codingame, et je ne comprends pas le message d’erreur :
SyntaxError: invalid syntax
at Answer.py. not in a function on line 17
(c’est la ligne du else if)
voici mon code, si une bonne âme passe dans les parages…

import sys
import math

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

result = 0

n = int(input())  # the number of temperatures to analyse
for i in input().split():
    # t: a temperature expressed as an integer ranging from -273 to 5526
    t = int(i)
    if math.fabs(t) < math.fabs(result) :
        result = t    
    else if ( math.fabs(t) == math.fabs(result) ) :
        if t > result : # found same value, but positive
print ("resultat : ", result)

# Write an action using print
# To debug: print("Debug messages...", file=sys.stderr)



It’s elif in Python, not else if.


It’s elif in Python, not else if.


Thanks !
I’am Pyhthon beginner, I’ve been found out :wink:
Best regards,


It appears that the C++ test cases are broken. Here are my results for the first 2 (“found” is my answer, “expected” is the test case’s answer):

Simple test case
Standard Output Stream:

Found: 0
Expected: 1

My Explanation: 0 is closer to 0 than 1

Only negative numbers
Standard Output Stream:

Found: -1
Expected: -5

My Explanation: -1 is closer to 0 than -5


You can have a look at the test cases using the button at the top left corner of the testcases panel:




je confirme la remarque de NewBo merci pour l’info.


i check mi code en C#, and it works perfectly, but in two test (3,4), not work, and when i send my answer even test 1 fails. plz check it


There is most likely one (or more) bug(s) in your code. Please check it.


My solution passes all the tests but when I submit, the score computer seems to freeze.


We had an issue yesterday with the submits. It’s solved.