Defibrillators puzzle discussion

Hmm, that’s weird, “Test 3 Complete file” was failing for me all the time. Even when I used the other formula mentioned here. It always calculated CRR as the closest one. But when I submited code even with the failing test I got 100 %. Not sure if there is a bug in my code (I am learning GO) or somewhere else:)

Hi, I’ve just understood why you failed test 3 (I did too). Some defibrillators have the same location name, so if you keep that name in a variable, it will be erased by the next to come (I’m not sure this is really clear in English sorry).
You had to find “Caisse primaire d’assurance maladie” in that test 3, but there are 2 lines with that name : first was closest, but was erased by the second which is very far : so the next closest is finally CRR !

1 Like

Alright! Yeah that will be it probably. I used map where street name was a key, so if there would be a different device on the same street later on it would rewrite that one. Thanks a lot!

1 Like

Hi, same problem for me. All tests passed but when I submit I fail the “single possibility” one !
Must be something to investigate behind that ; what does “single possibility” mean ?

Just reached 100 % using good old Pythagoras’ formula instead of that overcomplicated one provided by CG…

thanks mate!

but why doesn’t the provided formular work for the complete list tests? it didn’t time out - I just got a unexpected result - like my program knows about the road conditions :stuck_out_tongue:

1 Like

You did it wrong and got lucky. Hint: explorers in Antarctica don’t do it that way.

Could anybody put here the correct calculations for the first record, please? I need the correct reference to compare.

I have:
1;Maison de la Prevention Sante;6 rue Maguelone 340000 Montpellier;;3,87952263361082;43,6071285339217
LON(rad): 0.0677104433621504 LAT(rad): 0.761087970257301
distance(km): 98.0960843753421

but something is wrong.
PS. The problem was the colon separator in initial user coordinates… Once again be aware of colons! :wink:

Output from my code (values are rounded in the error output but not in the code)

Starting from (3.8795, 43.6082)
Radians: 0.0677, 0.7611
Distance to Maison de la Prevention Sante (3.8795, 43.6071) is 0.1166
Radians: 0.0677 0.7611
Distance to Hotel de Ville (3.8965, 43.5987) is 1.7280
Radians: 0.0680 0.7609
Distance to Zoo de Lunaret (3.8739, 43.6396) is 3.5217
Radians: 0.0676 0.7617
Maison de la Prevention Sante

Hope that helps.

1 Like

Thanks for the fast answer.

Strange i did all the 4 challenges correctly, but in the end only get 75% because the first one did not count. Can someone help me pls.

same situation here, no idea what is the 1st validator…:neutral_face:

ok, je viens de resoudre ce même problème, peut etre t’as aussi défini par défault une distance minimum, essayer de donner une valeur plus grande comme 999999, hope it can help U ; )

2 Likes

was the same problem for me, i declare a minimum distance 1000 as default and faild at 1st validator, i tried to change the min distance to 999999 and it worked.

1 Like

Not sure why, but I opened this puzzle again and now it sais it’s complete at 100% XD I did not change anything in it recently… And by the way, thanks for the tip but I was not using a big value for initialisation but -1 as a “uninitialized” mark so it’s not possible to encounter minimum distance problems with that method in theory ^^

EDIT: Turns out the problem for me was a C++ specific problem: while reading the input data you have to call an extra getline() before you start reading the defibrilators infos in a loop.

I have the same issue in “Exact Position” and I cannot find any input with "Cimetiere …

I am using PHP.

Any help on this ?

Thank you, I had this problem and was not understanding why Validator #1 was not working (on Python). Assigning a large value to this working variable solved my problem.

1 Like

Hi,

I’m stucked on 75% completion when submitting source (100% on test cases). The issue is we don’t have the detail of the purpose of the failure.

I firstly thought it was just a “precision issue”. So I check everything is declared as double, remove unnecessary computation involved in comparison to avoid floating point inaccurency (no sqare-root + no *6371). But it was not enough…

I thought there is time limits so I make sure the loop is performed once & minimize allocation & computation. Not enough :confused:

I thought “bad input format” should be managed in the final code, so I add exception management in case of ; Not enough :cold_sweat:

Any tip on what may miss? :slight_smile:

The current code I have write.

class Solution
{

static double K_DEGREE_TO_RADIAN = 180.0d/Math.PI ;
static void Main(string[] args)
{
    
   <moderator note: don't post full code, please>
    Console.WriteLine( bestSpotName ) ;
}

}

Thank you :slight_smile:

1 Like

Forgot one extra check on my post … I also investigate distance case equality (make a test with squaredDistance < bestScore & squaredDistance <= bestScore in case 2 solutions where possible)

The latitudes and longitudes are given in radians… no need to convert them on your own. Remove that part and give it a try.