Horse Racing Duals puzzle discussion

Bonjour, voilà plusieurs jours que j’essaie sans succès de passer le test numerous horses.

Ma méthode qui fonctionne pour les 2 premiers tests et les 6 premiers de la soumission
1/ je stocke les puissances (en les convertissant en entier) dans un tableau d’entier de dimension N-1 au fur et à mesure
2/ je trie le tableau avec un algo QuickSort
3/ je crée un tableau contenant les écarts
4/ je sélectionne l’écart minimum

Mon algo de quicksort est bon car il marche avec le test 2. Il est rapide car il passe pour le test Numerous Horses sans time out. Mais inexplicablement j’obtiens des écarts négatifs…

C’est extrêmement frustrant. En regardant sur le forum, je vois que certains ont été confronté il y a plusieurs mois à un problème similaire. Quelqu’un pourrait m’expliquer ce qui cloche ? est-ce un bug dans les tests ?

Merci d’avance

Can someone help me with “Horses in disorder” in Java? I can’t pass it and it would be cool to see the input.

And also, is the custom test case buggy?

You can see the input of any of the test cases. Do you see the button that looks like a grid of lines near the bottom-right corner, just to the left of the word “Actions”? Click that button to see the input for the test:

As far as I know, the Custom test cases are not buggy. I use them frequently, and have had no problems.

  • danBhentschel
2 Likes

Yep, so, mine code passes all tests but it isnt right (code doesnt cover all possible combinations). Think creators should check it and fix.

Ok, I will try it… I solve it in Java ( a piece of cake).
Then in bash I try a simple bubble sort (not enough), then to put input at the correct place not enough…
No I will try you solution =° I hope it will work

Someone got a little help about the kind of sort to use in this language? I’m tired to try to implement each time a new way to sort element… =(

try the console sort

Thanks for your answer, I’ve already resolved the achievement and the 100% now. My next problem was the difference between two elements in array (I was using arithmetic expression and it seem to be slower go through two sub variables)

Well, I know how to do this puzzle (I already did it in 16 different languages). But for some reason the sort function in PHP is not fast enough for the last validator in my case… Is there a better way to do it ?

I found my mistake. Therewas an extra carriage return after the end of the code

This is unfair! Why should I solve this in Bash? I don’t know this language at all! :rage:

1 Like

I got 100% for this puzzle, but I only got two achievements out of three.
If it is possible, has Anybody achieved 3? :relaxed:

Hi,

I managed to finish this puzzle but I don’t understand :

  • why my code in JAVA can’t validate the test 5 and 6 (I optimized my code, I used a TreeSet) ?
  • why my code in JAVASCRIPT have done them all (100% succes) but only make me win 2/3 Trophy ?

Thank you in advance :slight_smile:

Je parle aussi Français.

You need to solve it in Bash to unlock the 3rd one.

Bonjour,
ne parlant pas l’anglais j’essaye de comprendre les post.

Je suis en PHP et comme pas mal de personne je fini les tests IDE.
Mais pour les évaluations il me manque “Horses in disorder”.
Je sais que les évaluations sont différente des tests IDE.

Je crois comprendre qu’il faut éviter “sort” pour trier le tableau des puissances des chevaux, d’après les com.
Du coup je ne comprend pas du tout comment faire.

Si quelqu’un a une solution en php je suis preneur.
Merci d’avance.

Salut tous le monde.

Je viens de comprendre le pourquoi.
Après avoir passé quelques temps à chercher, la réponse est toute bête.
Le titre de la validation induis en erreur.
Vos chevaux sont surement dans le bonne ordre.

Lisez bien les consignes. La réponse est dedans.
Bonne journée à vous. En espérant avoir pu vous aider.

1 Like

Hello.

I have an simple question for you.

I am using C# to solve this problem, and I am using function “Array.Sort()” to sort the power of horse.

But in the second test the array has 10 elements and I have no idea why last element does not have the max value ?

For example:

Array.Sort(horses)

horses[0]=3
horses[1]=5

horses[7]=17
horses[8]=2
horses[9]=5

Can anybody explain that ?
Thanks for any help.

Je confirme en C++, pour éviter le problème de timeout, il faut utiliser un Qsort.

So, I found some caveat in solving this problem.
This problem is quite trivial, but if you are unfamiliar with the platform then you are in for a bad time, like I did.

I didn’t write a quick sort or merge sort for this problem, instead I was wrote a binary tree and tried dumping all the data into the list in-order. However my program didn’t even manage to fill the binary tree fast enough, which should only be O(logN). So my head got big and had to scratch everything I wrote. Magically a single qsort solves all this problem. So my guess is that because when I’m making the binary tree, my frequent memory allocation fragmented the heap(?) or dynamic allocation in codingame is just very slow, I’m not sure which one. Or maybe my tree is just very unbalanced :(.

Im doing it in JavaScript, but I don’t really understand how to do this puzzle, I can do some others, but this one is just…hard…not easy like the name suggests. Someone help me!