# Defribillators puzzle discussion

#228

They are given in degrees, not in radians.

#229

Awesome.
Lat/long are given in radians, not in degree as said MrAnderson

Thx!

#230

I found my mistake âŠ it took me a while and so obvious !!!
I hate myself in these case

#231

Bless u sir.

#232

[solved]
Hi,
I have got a mistake for test number 3âŠ
I found nearest âCaisse dâassurance retraite et de la Sante au travailâ (distance=0.0218670137907) than âCaisse Primaire dâAssurance Maladieâ (distance=0.0329447601689)
the test #1 2 and 4 are ok but this doesnât workâŠ
Iâm with python
Have you got an idea for my problem ?
Thanks a lot
I found the problem in my formula for distance.

#233

Hello tous le monde !

Jâai bien aimĂ© ce puzzle mais je vous conseil de ne pas prendre la formule donnĂ© dans lâĂ©noncĂ© pour le calcul de distance car perso câest ce qui faisait buger la pgâŠ
Mais plutĂŽt celle ci

## d = R.acos(sin(a).sin(b)+cos(a).cos(b).cos(c-d))

Elle fait peur certe fonctionne trĂšs bien et le must câest que cela se fait en une Ă©tape et pas trois !

a = Lat A
b = Lat B
c = Long A
d = Long B ----- Bien sur toutes ces donnĂ©es sont quand mĂȘme a rentrĂ© en radians

#234

I had the same problem. donât use the provided triangulation formula. Simplify it :

Sqrt((LON1 - LON2)^2 + (LAT1 - LAT2)^2)

That fixed may problems. I was using doubles in C#.

#235

JavaScript.

I have an issue where I pass all test cases in the IDE, but then when I submit I fail on âComplete fileâ. I canât figure it out why. Is anyone here able to help?

``````const radCon = (180 / Math.PI)
let shortestDistance = Infinity;
let nameOfShortest = '';
for (let i = 0; i < N; i++) {
let [,name,,, long, lat] = readline().split(';');
long = long.replace(',', '.') * radCon;
lat = lat.replace(',', '.') * radCon;
x = (long - LON) * Math.cos((LAT + lat) / 2);
y = lat - LAT;
distance = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2))
if (distance <= shortestDistance){
shortestDistance = distance;
nameOfShortest = name;
}
}
print(nameOfShortest);``````

#236

DO NOT forget to add â.0â at the end of numbers when computing with floats or doubles !

#237

The debugger in the browser doesent seem to want to replace commas with dots. So i cant parse the strings to doubles and my whole algorithm doesent work. Feelsgood when you cant even test your code.

#238

In Java, replace returns a new String, it doesnât modify the current String.

https://docs.oracle.com/javase/7/docs/api/java/lang/String.html#replace(char,%20char)

actually, you can check the first pitfall of this playground: https://tech.io/playgrounds/1097/the-most-common-java-pitfalls

#239

Input values - that includes lat lng of User (first and second line of input) and not only - as I assumed - data for defribillators. Many minutes were lost

#240

Thanks for the hint

#241

Mate, you saved me so many hours here! Ty a lot!

#242

I dont get it inside the IDE all test work with sucess. when i submit the
âsingle possibilityâ test appear as Red. Why??? 0.o

#243

StrangeâŠ

In VS my code works correct, but in website - wrong.

Website cannot round a double value with many digits after â , 'âŠ
Iâve tried Math.Round, but it doesnât work

#244

Bonjour,

jâai fini lâexercice mais lorsque je soumets mes rĂ©sultats, lâexercice nÂ°3 nâest pas acceptĂ©.

Jâai changĂ© mon code plusieurs fois mais rien ne change, pouvez-vous me conseiller?

#245

Well, the same old song - program passed all testcases in IDE, but failed on âComplete file 2â on Submit. Iâve tried all recomended - using different formulas, removing converting from degrees to rads, changing double to long double but nothing helped. And CG doesnât give any clue what goes wrong. Thanks for killing my motivation

#246

Understand. It was timeout problem. After some optimization of my code (C++) it passed. But I still think, that CG should tell the type of error - e. g. âtimeout errorâ or âwrong answerâ or something like this

#247

Iâm surprised that test set allow passing with wrong formulae. Iâve misspelled some part of it and was ok, other people simplify formula, some of them even overlook to convert to radiansâŠ Maybe add some test cases with points far away, to make errors be visible?