Temperatures puzzle discussion

#540

What language is that? In most languages a single `=` is an assignment and a double `==` is a comparison. There is a big difference. At `if (n=0)` you use an assignment where you want a comparison.

#541

Thatâs right, but JS is very permissive.

And thatâs the first mistake, you are setting n to 0 here, you should always use === in JS to compare object.

2nd one: in for (var i = 0; n; i++), you will never enter that since n equal 0
3rd one: Itâs an infinite look, if n > 0 because you will never reach the condition, I bet you wanted to write i < n instead of n.

4 incoming one, since you are using JS be careful when playing with string because â-2â < â-20â === true

#542

I donât understand French but Iâve been trying to get this challenge working on C and your code works for me - thank you. It helps me to understand better (I always prefer to get these challenges without help but I think this was really difficult on C)

#543

May be that i donÂ´t understand the systematic. I get never the chance to type in some temperature values. So may be i understand something wrong. My first test-programm was in javascript in the way:

``````var n = parseInt(readline()); // the number of temperatures to analyse
var i;
var tmin = 9999;
var tres;
var temps;
for (i = 1; i <= n; i++)
{
// n Temperaturen eingeben
temps = readline(); // the n temperatures expressed as integers ranging from -273 to 5526
var tempABS = Math.abs(temps);
if (tempABS <= tmin)
{
tmin = tempABS;
tres = temps;
}
}
// Write an action using print()
// To debug: printErr('Debug messages...');
print(tres);
``````

But i never get a prompt to put in number of values and the values. So may be i am totally on the wrong way. I would be happy for a hint how this âparseInt(readline())â statement is to implement in the code.

#544

You can copy and paste your code into the puzzle IDE âcode areaâ, or type your code directly there. Then click the âPlay Testcaseâ button to try your code again a set of input.

#545

yes, but the special part where you type in the numbers of temperatures and the temperatures itself is the problem i donÂ´t understand. Can you put this in a loop, or are these input-lines
`var n = parseInt(readline()); // the number of temperatures to analyse`
and
`readline(); // the n temperatures expressed as integers ranging from -273 to 5526`
fix and simulated input? I dont get any prompt to input anything.

#546

All puzzles are designed to offer no prompt. All puzzles are designed to have several pre-defined inputs that you can trigger by clicking on the test button or the submit button.

I assume the architecture of this site is like that:
Once you pasted your code into the IDE and clicked a button to run it, your code will be uploaded to the server. The server will input data to your code and then check its output. The server will send back the results (pass or fail, debug messages, etc) to your browser. The readline() function reads data from the server. There is no way for you to key in anything real time.

If you really want to use your own data as input, you can use the âcustomâ tag to define the input and output (you define your own output), and then run the test to see whether your code produce a matching output. The logic is just the same. The server has some prepared input data. The code is uploaded and executed in the server. You finally see the execution result.

#547

Ok. So by example, itÂ´s possible to use the given code
`readline(); // the n temperatures expressed as integers ranging from -273 to 5526`
in a for-next loop or whatever, and the input is coming without direct input automatically from the system, right?

#548

Yes Itrata. You can rely on the stub as a starting point to code. Most of the time it will provide correct looping to read data from the system. You need to add in suitable codes after the readline() to handle the data - keep it, process it, whatever.
Welcome aboard to this maze of puzzles.

#551

Hi There!

I think I found a bug in the 2nd testcase (java). The input I get from the program is {-12, -5, -137, 5}.
First off, the testcase is called only negative numbers, but I do get a positive number. No biggie, the program should still be able to deal with that, but the problem is more is in the error I get when running the test case.
I get the following message: Failure Found: " 5" expected â-â.

Cheers!

#552

The second test case is
3
-12 -5 -137

Wherever your program got the 5 from is the problem. Getting 4 numbers when the first line said there were only 3 should be an indicator.

#553

Hello, can you help me?

I have passe all test cases besides â2 âOnly negative numberâ, i think there is a bug.

There is my code in C++

``````int main()
{
int n;
cin >> n; cin.ignore();
int min;
for (int i = 0; i < n; i++)
{
int t; // a temperature expressed as an integer ranging from -273 to 5526
cin >> t; cin.ignore();
cerr << "temperature is " << t << endl;

if (n == 0)
{
min = 0;
break;
}

if ( min == 0 )
{
min = abs(t);
}
else if (min > abs(t))
{
min = abs(t);
}
}
cout << min << endl;
}
``````

There is the IO of second test case:
Standard Output Stream:
temperature is -12
temperature is -5
temperature is -137
5
Failure
Found: 5
Expected: -

Can you please explain me why we are expecting â-â (minus symbol) ?

#554

it expects the â-â character because the whole answer is â-5â

#555

Dâoh, thanks. I found the issue in my code. It was a late night

#556

Are the two Python3 codes below different?

``````i = input()
for t in i.split():  #code works fine
``````

vs

``````for t in input().split():  #error occurs
``````

Why doesnât my âforâ loop work if I did not define " i = input() " ?

I managed to solve 100% but I donât understand why the error occurs.
Hope someone understands what Iâm askingâŚ Thanks!

#557

bonjour
puis je avoir de lâaide pour le puzzle temperatures
merci

#558

Je pense que ce fil en est rempli !

#559

Bonjour,

Jâai un code VB.net qui passe sans problĂ¨me tous les tests (y compris les cas limites : pas de tempĂŠratures, tempĂŠratures identiques mais signes opposĂŠsâŚ) ; mais une fois soumis, les validations apparaissent en rouge comme si câĂŠtait faux. Il me paraĂŽt difficile dâ'avoir âtout justeâ aux tests et âtout fauxâ Ă  la soumission, surtout avec un problĂ¨me qui nâest pas trĂ¨s difficile dâun point de vue algorithme.

Pouvez-vous regarder plus en dĂŠtail ? Merci

#560