In VS my code works correct, but in website - wrong.
probably thats because your system locale uses comma as decimal separator.
But for IDE you have to replace commas with dots. Alternatively you can specify the locale explicitly.
In VS my code works correct, but in website - wrong.
probably thats because your system locale uses comma as decimal separator.
But for IDE you have to replace commas with dots. Alternatively you can specify the locale explicitly.
I had the same problem in python3. Since you do not really need the real distances, but only have to compare them, there is no need to multiply with any constant; even taking the square root is not nessessary.
You need to code a Dijkstra or A* algorithm so you need to calculate the square root (but not to calculate the real distance, proportional is OK).
If you are stuck at file complete 2, donât use the formula given and conversion to radians. Just search on this topic the formula or on the web.
My problem actually is that input has different formats and I donât know how to deal with it.
1 - 2;Hotel de Ville;1 place Georges Freche 34267 Montpellier;;3,89652239197876;43,5987299452849
2 - 1;Maison de la Prevention Sante;6 rue Maguelone 340000 Montpellier;04 67 02 21 60;3,87952263361082;43,6071285339217
3 - 76;Universite Montpellier 1 UFR Staps (Palais des Sports);;;3,84872346174789;43,6401970759746
May I have any hint? Thanks
Just solved that problem making 3 different kind of possible inputs, and treating them differently when splitting their strings. Finally, success!
thatâs a phone number. Donât bother with it; you should handle it as string (pointer to char, etc.)
Javascript
For the ffirst validator, hereâs my code :
> if (N===1){
print(defib[1]); } print(defProche);
defib[1] equals to the name of the defebrilator
defProche equals to the nearest defebrilator, so in the firs case , they sould be equals.
But i print both of them and it still works .
And if i do this :
> if (N===1){ > print(defib[1]); > } > else{ > print(defProche); > }
it works too
how is it possible?
I know itâs been a while since you asked your question but I think your issue is that you have the latitude and longitude values reversed when you parsed the input line. I had similar distances in my calculations and I realized that was my problem.
Hello everybody.
I finally got a 100% result score, but I am not happy with it. I have two issues with this puzzle, the first one being quite a serious oneâŠ
I use C# as my language of choice.
The implentation of the formula for calculating the X-distance might have an issue. The formula contains of two parts:
Regarding this second (correctional) part, I suspect a bug in the submit-testcases. The cosinus function expects a parameter representing the angle in radians, but I received a 100% score only after I (wrongly) passed the angle parameter in degreesâŠ!.. In my opinion, this will actually result in very wrong latitudinal corrections, and thus in very wrong distances!
As stated in the puzzle description, the commaâs should be replaced with dots to be able to convert to numeric values.
As smart as I try to be, I tried an alternative route by using the TypeConverter class provided by the .NET Framework.
The following code runs correctly in my local Visual Studio installation, but fails with an exception in the online IDE:
string text = "3,1415926"; // note the comma!
var converter = System.ComponentModel.TypeDescriptor.GetConverter(typeof(double));
var culture = new System.Globalization.CultureInfo("fr-FR");
double value = (double) converter.ConvertFromString(null, culture, text);
Any clues why this code does not work in the online CodinGame IDE?
Thank you very much for your patience! Happy programming!
There is a problem with their input, usually the first line after the N is null so if you try split the first in.nextInt() you will get error, add a condition that checks if the string.equals("") and if its true you just skip that line.
what exception did you get?
Hello _CG_Thibaud. Thanks for your response.
I just tried to reproduce the exact exception, but I failed to do so. For some reason, the TypeConverter code now works fine! Great!
Regarding the cosinus issue⊠I made a mistake converting degrees to radians. So now that code works fine too.
I have published my updated code and I have updated the puzzle rating from three stars to five.
Thanks again.
Bon je comprends pas. Tous les tests passent sauf le 3. Je trouve CRR au lieu de Caisse Primaire dâassurance maladie.
Jâai enlevĂ© les virgules des nombres et les ai remplacĂ©s par un point.
Jâai converti les angles en radians avec cette formule
radian= degree*(pi/180)
Jâai testĂ© toutes les formules de calcul de distance donnĂ©es dans le sujet et sur ce forum et CRR est toujours plus proche que Caisse Primaire dâassurance maladie.
It rejects my solution saying it is hardcoded.
I id not hard code.
I donât even know what does that mean.
Please help
Regarde bien la liste des dĂ©fibrillateurs, je mâattendais Ă ce que ça aille de 1 Ă n par incrĂ©ment de 1 mais bizarrement, quand tu listes, ça passe du dĂ©fibrillateur 166 Ă 168⊠Finalement quand tu print la longueur, ça te dit quâil y a 167 dĂ©fibrillateurs alors que le dernier de la liste Ă le numĂ©ro 189. Si tu ne le fais pas dĂ©jĂ , essayes donc plutĂŽt de tourner sur les numĂ©ros des dĂ©fibrillateurs plutĂŽt que sur un range de 1 Ă n
Try d = sqrt((xb-xa)^2 + (yb-ya)^2) instead of the âcomplexâ formula in the statement⊠That worked for meâŠ
OMG. Itâs been hours since iâve tried to figure out the same problem. Thank you !
Hello, this is a fairly generic question I think. My console output is not showing a large number of entries from my for loop. It jumps from defib 16 to 165. Iâm pretty sure the program did work on all the entries between 16 and 165 since the closest defib updated but I would like to see those entries as well. Is there a UI setting Iâm not familiar with?
Thanks
Iâm trying to use these formula, and pass all tests , but just get 75% when i submit the code.
I didnât pass the Complete file 2 âŠ
double d2r(double d) {
return (d / 180.0) * ((double) M_PI);
}
double r2g(double d){
return d * M_PI / 200.0;
}
double distance(const Position me, const Position side){
double x = r2g((d2r(me.lon)-d2r(side.lon)) * cos((me.lat + side.lat)/2.0));
double y = r2g(d2r(me.lat)-d2r(side.lat));
return sqrt(pow(x,2)+pow(y,2))*1000;
}
Whatâs wrong with my formula ?