Temperatures puzzle discussion


#716

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

#717

wait, what?

image


#718

Yeap sorry didn’t read that.


#719

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


#720

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++…


#721

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


#722

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)

print("result")

#723

It’s elif in Python, not else if.


#724

It’s elif in Python, not else if.


#725

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


#726

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:
1
-2
-8
4
5
0

Failure
Found: 0
Expected: 1

My Explanation: 0 is closer to 0 than 1

Only negative numbers
Standard Output Stream:
-12
-5
-137
-1

Failure
Found: -1
Expected: -5

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


#727

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

image

image


#728

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


#729

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


#730

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


#731

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


#732

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