Defribillators puzzle discussion


je rencontre in problem assez bizarre avec la convetion des string en double en c++ pour exemple voici ce que j’obtients avec le premier test:
43.6071 latitude exact
3.60713 longitude avec erreur bonne valeur 3,87952263361082

43.5987 latitude exacte
3.59873 longitude avec erreur bonne valeur 3,89652239197876

43.6396 latitude exacte
3.63959 longitude erreur bonne valeur 3,87388031141133

je ne comprends pas ou est le problem


CRR post

I had a problem with the third and fourth test. I got the wrong output no matter what formula I used.

I found out that the replace didn’t replace all the comma for point. I used the replace on both the lattitude and longitude seperately and it work like a charm,


All tests run finely for me, but after submitting the 3rd scenario doesn’t work.
Anybody else has a same problem?

  • Math.PI / 180


use it cos (data)?, data = data* Math.PI / 180


Thanks, now it works. But could you explain me why it was needed?


In many (most) languages, the arguments for trig functions have to be entered in radians rather than degrees. Pi radians equals 180 degrees.


Got the same case with the 75%.
Thank you for pointing me to the right way!
I just inited a distance with Infinity value – seems it fit here the best


Of course, Kristof! You takes data in degrees (LAN, LAT), but in general prog. language need it in radians to calcylate cos, etc. So you need to convert this argument so cos function works correctly. Otherway the result is wrong. In general, as we know from math, there are no big difference when cos calculates very low angles, plus you had same mistake in results (distances) what you compare, thats why the result of comparisation was often right. But, as you see, not alway =). I had almost same proble, cause I tried to convert vise-versa, from rad to grad. That was my strange mechanical mistake =)



I’m facing a problem. I’am coding in C#.
When i parse a string to double, then the comma disappears (While I should have a dot instead of the comma).

Exemple :

string LON = Console.ReadLine();
Console.Error.WriteLine("LON = " + LON); // 3,879483
double dLON = double.Parse(LON);
Console.Error.WriteLine("PARSE DOUBLE LON = " + dLON); // 3879483

I do not understand why that makes that, in Visual Studio it works !

Can you help me please ?


Culture and regional settings must be different between CG and your machine.

This link suggests some solutions:

Myself, I just did string.Replace before parsing.


You are right.

I did :

double dLON = double.Parse(LON.Replace(",","."));
Console.Error.WriteLine("PARSE DOUBLE LON = " + dLON); // 3.879483

Thank you.


I failed one of the tests when I was hard coding which character was the comma, and building the string around it. Once I switched out the string builder with replace it passed all the tests. So I’m assuming one of the test cases has the comma in a different place than all the examples. Hope this helps someone out.


Je pense qu’il y a un bug avec les 2 succès de ce puzzle. Je l’ai fini a 100% en python3 mais ça ne les a pas débloqué.


Ça arrive mais il faut 100% aux validateurs.


C’est le cas. Ca semble être corrigé, merci :slight_smile:


OMG, finally cracked it! My problem? Parsing the coordinates from string to double, in combination with dev’ing in VS.
Basically, this conversion works in VS:
double.TryParse(longitude, out longitudeDegrees);
And here on codingame:
double.TryParse(longitude.Replace(’,’, ‘.’), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out longitudeDegrees);
Did anyone else see this behavior, or am i the only one making things so complex? :slight_smile:


Nope, this is a fairly common complaint in this thread. Someone else had the same issue about 6 posts up.


Hi all
Im having some problems with the 2nd test of the submit “Complete file”. I passed the 100% of the tests in the coding phase but when I submit i only get the 75%.

I didn’t hardcoded and I have no idea why my code is wrong.

Any idea?

Btw, Im programming on Javascript.



This maybe :wink: