Can you be more specific please? On which test? which language?
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
In my case itâs C#. All the tests that have only negative numbers as input
Yeah, you didnât understand the subject:
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?
Merci dâavance.
#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>
OK merci pour cette information. Entre temps jâai utilisĂ© la fonction FIND et jâai eu 100%.
Encore Merci!!
Bonjour,
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.
En effet,
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 ^^â
Pas de souci
True.
In my case, I updated the code to check the input only if N != 0.
I have a question, I am doing the code in C#,
my code fails on negative numbers because as I am about to give the answer, the code is incorrect because of the minus sign preceding the number.
Any workarounds around that?
I just donât know why this happens.
What is the error exactly, can you give a small piece of your code here?
EDIT: code now deleted to let other users search
Here is my code, idk where is the error
The error is with the result is a negative number and I canât understand why, hope someone can help me, Iâve made code way more complex than this and its killing me that I fail on something so simple xD
Have you read that? That probably is where you failed.
or that