Hello I think in Python3 there is something weird in the original code :
TEMPS = input()
This does not work in the third case with no temperature. And there is only 3 cases when we submit there are several more cases which are not convenient to debug without the given input.
Have the same issue, I have tried faking the input with the data the validation tests use in the puzzle itself and I get correct results, but on submit I have all the tests with all negative numbers as failed
Display 0 (zero) if no temperature is provided. Otherwise, display the temperature closest to 0, knowing that if two numbers are equally close to zero, positive integer has to be considered closest to zero (for instance, if the temperatures are -5 to 5, then display 5)
Read the bold part carefully. That mean that in your example the answers are -10 and -7. You dont have to revert the sign, the last sentence only applies when two numbers are equally close to zero.
positive integer has to be considered closest to zero
Does mean that 5 -5 -> 5 but if there are only negative numbers then -5 -5 -> -5
EDIT:
Plus, if you had clicked “submit”, you could have seen a hint:
It works when inputs contains only negative numbers: : {-15 -7 -9 -14 -12} -> -7 (250 pts)
When two temperatures are as close to 0, then the positive wins: {15 -7 9 14 7 12} -> 7 (750 pts)
It works with two negative temperatures that are equal: {-10 -10} -> -10 (250 pts)
Nice idea, terrific picture!
But I had some problems with the test routine: It seems to regard only the first position of the output! All your test cases have positive numbers lower than 10 as correct output, so this does not have any direct consequences.
But unfortunately your test cases do not cover all possible errors, so it would have been nice to have a full set of tests.
In my opinion, the following test cases are missing:
all temperatures are negative (correct code would fail with your current test routine)
temperature null is included (correct code would success with your current test routine)
lowest / highest possible temperature as only temperature (correct code would fail with your current test routine)
The tests when you hit the ‘submit’ button are more complete:
It works when inputs contains only negative numbers: : {-15 -7 -9 -14 -12} -> -7 (250 pts)
it works with -273 alone (250 pts)
It works with 5526 alone (250 pts)
I may not be the full set of amwesome and hardcore tests, but it’s sufficient to see if you get the exercice. Plus remember that is it only an Easy puzzle, so i don’t think too much improvement are necessary, coz it will remain easy anyway.
Bonjour,
J’essaie de passer ce puzzle en C++.
J’utilise strtok_r pour récupérer les nombres dans le fichier.
Le problème est que je me retrouve avec le message d’erreur suivant :
strtok_r was not declared in this scope
Dans le puzzle, il y a bien un include de STRING.
Est-ce que quelqu’un c’est déjà retrouvé avec le problème?
Suis-je sur la mauvaise piste?
#include <string> ou #include <string.h> ou #include <cstring> ?
Le premier ne doit pas inclure ce genre de fonction.
Les deux derniers oui (oui je sais, ça fait bizarre, mais le premier correspond à la “string c++” alors que les deux autres permettent de réutiliser les fonctions string du C).
je penses comme l’a dit @cup_of_tea, de base il n’y a que les include pour la classe std::string (qui soit dit en passant est largement suffisante pour ce puzzle).
Si tu tiens vraiment à utiliser strtok et strtok_r, il faut suivre le conseil de @cup_of_tea et ajouter #include <cstring>
J’ai fais l’exercice en java et lorsque je soumet mon code qui passe bien les tests j’ai deux points qui ne sont pas validés alors que les résultats affichés sont les bon :
When two temperatures are as close to 0, then the positive wins: {15 -7 9 14 7 12} -> 7 (750 pts)
par exemple ce morceau c’est pas validé…
En tout cas merci pour ce site et bonne continuation !
La flèche ne donne pas le résultat que tu as renvoyé, mais le résultat attendu.
Donc {15 -7 9 14 7 12} -> 7 veut simplement dire que la réponse est 7, mais pas forcément que ton code a affiché 7.
Les tests de validation diffèrent des tests utilisés pour les exemples sur l’ide. Il est donc simplement possible que le code soumis est faux, mais passe les exemples.
Après vérification - et correction - j’avais fais des erreurs dans mon code mais il passait quand même les tests de base, désolé pour le dérangement et merci pour la réponse ^^’