# Defribillators puzzle discussion

#290

Bonjour.
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

#291

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,

#292

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

#293
• Math.PI / 180

#294

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

#295

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

#296

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

#297

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

#298

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 =)

#299

Hello,

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 ?

#300

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

Myself, I just did string.Replace before parsing.

#301

You are right.

I did :

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

Thank you.

#302

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.

#303

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é.

#304

Ça arrive mais il faut 100% aux validateurs.

#305

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

#306

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?

#307

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

#308

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.

THX

#309

This maybe