Defibrillators puzzle discussion

Feel free to send your feedback or ask some help here!

1 Like

Take care of the “,” character in input values !
I’ve lost many minutes because my string to float conversion get only the integer part of the coordinates give as input (longitude, latitude).

Faites attention au caractĂšre ‘,’ (virgule) dans les valeurs d’entrĂ©es.
J’ai perdu plusieurs minutes parce que ma conversion de string Ă  float ne prenais pas en compte les chiffres aprĂšs la virgule dans les coordonnĂ©es (longitude, latitude) donnĂ©es.

17 Likes

Bon, j’ai beau tourner et retourner mon code dans tous les sens je comprends pas : tous les tests d’entrainement sont OK, et tous les tests de validation sont OK Ă  part le premier ??? J’ai codĂ© ça en C++, quelqu’un d’autre s’est retrouvĂ© dans cette situation ?

6 Likes

Les tests d’entrainement contiennent tous plus d’un dĂ©fibrilateur, le premier test de validation est le seul avec une seule possibilitĂ©. Peut-ĂȘtre que ton algo prend les dĂ©fibrilateurs forcĂ©ment deux par deux ? Qu’il doit obligatoirement faire une comparaison avant de sortir un rĂ©sultat ?

1 Like

Bein non justement, en gros mon algo calcule la distance de l’utilisateur au dĂ©fibrilateur pour chaque dĂ©fibrilateur et garde le minimum en mĂ©moire. A chaque nouveau dĂ©fibrilateur le min est mis Ă  jour si besoin (donc on compare jamais 2 Ă©lĂ©ments mais uniquement 1 Ă©lĂ©ment et le min). A la fin du prog on retourne ce min.
Le min est initialisé à -1 et mon test pour mettre à jour le min a un cas particulier qui passe toujours dedans si min == -1.

Peut-ĂȘtre un truc qui se passe mal niveau parsing alors ? Je remarque que dans les tests d’entrainement la solution n’est jamais le dernier. Peut-ĂȘtre que tu ignores le dernier ? (et donc, dans le cas qui foire, le seul, ce qui est balaud XD)

Oh, bien jouĂ©, c’était bien le problĂšme ^^ Le dernier Ă©lĂ©ment n’était jamais lu
 Et tout ça grĂące Ă  la magie du getline(cin, line); qui gĂ©nĂšre une ligne vide quand on l’appelle aprĂšs une sĂ©rie de cin >> val; >_< Du coup ma boucle de lecture lisait une ligne vide en premier et ignorait la derniĂšre
 Merci pour l’aide Lilian ^^

2 Likes

De rien ! Et ouais, cet exo est plein de trucs relous à parser, et cin se comporte bizarrement c’est facile de se faire avoir^^

2 Likes

I’m using Double, convesion work good. = )

My code passed all tests in “Defibrillators”, but in final score it says that program haven’t passed “Complete file 2” test. What’s wrong?

7 Likes

In Java, I needed to convert chars “,”, to “.”. Exp: 34,780 -> 34.780.

1 Like

I have the same problem as Belinos. Despite having passed all four tests, my code only got 77% completion when it was validated because it allegedly didn’t pass “Complete file 2.” What went wrong?

1 Like

Formula povided for the measurement is too complicated. You can use a much simplier one, since we dont actually need exact distance in kilometers. Triangulation with sqrt((x1-x2)^2+(y1-y2)^2) works fine, no need to overcomplicate it with Earth radius and scalar vector multiplication


39 Likes

Aha! I figured that the formula was unnecessarily complicated, but I didn’t think it would hurt to use it as is. I was wrong. It turns out that by simplifying the formula, I was able to get 100% validation. Using the complicated formula probably caused a time-out during validation. Thanks for this important clue.

6 Likes

You’re welcome :slight_smile:

I’ve used both the simplified and non-simplified formulae (C++) and have code that passes all the tests, but fails the Exact Position round after I submit, giving me 77%.

It’d be nice to get an actual error message so I could fix whatever is wrong. Is this available someplace?

Is it possibly something to do with taking too long? (Comma conversion to decimals takes a fair bit of the program’s time. Shouldn’t really be significant, but perhaps?)

The Defribillators puzzle is very strange. I don’t know why, but passing all the tests doesn’t necessarily mean that you’ll pass the validation stage.

Since you’re having a problem with the Exact Position test, you might want to try using double variables instead of float. I can’t guarantee that it will work, but I think it’s worth a try.

Debugging sure is difficult in here =) I’m usually using a lot of printErr’s to find out what goes wrong(i’m a JS user).

Aside from that, it’s difficult to say, what have gone wrong in your case without looking at actual code. But i’ll try :slight_smile: First impression - it’s really matter of accuracy, try to use double, like elysius have already said. Timeout is unlikely, since you’ve passed both complete files tests, and they are bigger. And comma conversion doesn’t make much of a difference in this scale.

Thank you so much
 it took quiet a while, until i noticed this


1 Like

Yeah! Thanks for this hint, now I got 100% validation.

1 Like