Temperatures puzzle discussion

Thanks a lot!

Bonjour. Je suis totalement débutant en code, et je n’arrive pas à résoudre ce problème. Je pensais utliser la recherche dichotomique pour le résoudre après avoir trié la liste mais je suis perdu entre tous les programmes que je trouve sur le net. Je travaille sur Python. Pouvez vous m’aider ? Merci

C’est le puzzle où il faut trouver la température la plus proche de 0 ?
Poste ton script en privé, on pourra t’aider.

so i’m using Rust: i get the smallest temp with using an if and comparing the read values against each other. For that i transform all temperature to a positive using the .abs() method. The problem i have now is that i am stuck and dont know how to display the coresponding negative number to my positive values

How about using an additional variable to store the corresponding negative number?

1 Like

No need to use an array to solve this puzzle. It can be solved just comparing every input to the last result in the for-loop.

i need help it asks for a one then a negative five

and im using java

And it’ll ask for different correct numbers (answers) for different tests and validators. That’s because your code must be general enough to solve all tests and validators.

The statement asks the output to be:

Display 0 (zero) if no temperatures are provided. Otherwise, display the temperature closest to 0.

With the following input, the closest to 0 is 1:

1 -2 -8 4 5

But if I change slightly the input, then the closest to 0 because -2:

-2 -8 4 5

So you need to find which one is closest to 0, whether it’s from the negative or positive side.

hello, I am having trouble with getting 100% on this coding game.
it states that I have done 100% on my test cases. However, when I go to submit it says that I didn’t complete test cases 3 but I have.
Can you give me some help with this.

Many Thanks

Tests and validators are different. Your code may not be general enough to pass all the validator cases.

hello there,
I am learning Python
Can’t get 100% with my code because of this validator that I don’t understand
“Two negative temperatures that are equal: {-10 -10}”
here is my solution
[Mod edit: Please avoid posting codes on the forum]
Can anyone give me a hint

The code you’ve posted is incomplete. Anyway, please try to avoid posting codes on the forum.

What does your code output if the temperatures given are -10 and -10?

It’s my first time doing a challange on this page. I dont understand how the console.log works. when i do i console.log() in the code, it won’t show on the console page on the left bottom…do i have to click somewhere to run my code?

Have you clicked any PLAY button below your code?

Also, if you want to display anything other than the answer, you have to use console.error instead.

Si une seule valeur est envoyée, tu dois la retourner telle quelle.