Defribillators puzzle discussion


#1

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


#2

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.


#3

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 ?


#4

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 ?


#5

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.


#6

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)


#7

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 ^^


#8

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


#9

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


#10

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?


#11

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


#12

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?


#13

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


#14

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.


#15

You're welcome smile


#16

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?)


#17

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.


#18

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


#19

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


#20

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