Using Python3:
Solved test #9 by using dtype=float on my sums. Apparently one of my computed numbers is higher than 2**32. I guess I’m not summing efficiently. So i’m finally at 100% after a few hours of headache.
Also if it’s the only one you’re failing, it’s most likely because of the remaining values that are calculated wrong after you’ve multiplied your cycles. (The wrong formula can work for the other tests even #10)
Thanks for the link @5DN1L. I have however did all kinds of testing with normal data and it works, as I have indicated in my previous post. Only when it starts to get to 10^9 problems arise.
I wanted to show my code in order for someone who has already solved the puzzle perhaps quickly pinpoint the problem. TBH I find it extremely inappropriate to not be able to post code at the coding forum. But it’s ok, I’ll post it on stackoverflow.
@5DN1L, yes you were right I did have some errors with these specific tests. However after fixing them I still have wrong answer for the big data cases.
This custom case may prove useful for debugging if you fail the last visible test (i.e. Test 6 “Works with a large dataset”) and the reason isn’t a timeout:
My code works. I have even tested the “large dataset” locally. It takes between 3 to 4 sec… how fast it is supposed to be ? I read about memoization, but I’m seriously unable to get where I can apply in my code.
J’ai appliqué l’algo de Floyd (lièvre et la tortue), puisque comme beaucoup le dernier test tombait en Time Out
Du coup, tous les tests passent maintenant… Je trouve bien les cycles et calculent le résultat en conséquence et juste… Sauf pour le dernier, j’obtiens bien un résultat mais faux (89750396502599 au lieu de 89744892565569)
Et vu la tête du jeu de tests, je ne m’en sors pas pour identifier ce qui n’irait pas !
J’ai créé plusieurs cas de tests localement, il fonctionne tous…
J’aurais besoin d’aide… Y a quoi sur ce dernier test bien qu’ils soient méga volumineux ?
On est bien d’accord, la detection de cycle se fait sur la référence des wagons qui contient les groupes et non la queue des groupes ?