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
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,
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 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.
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?
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.