I have tested your input and I’m getting the correct answer. Also I still not do not understand the difference between the input you have provided and the “Horses in any order” validator.
It’s funny how the report suggests that I learned Loops by solving this problem, but I solved it in Haskell, so… no, actually no, you can’t learn loops this way :).
Yeah I realized my mistake, thank you for your help.
Hi Suresh,
Check your sort.
For example, if you are using javascript, use
.sort((a, b) => (a - b));
instead of
.sort();
Cheers,
Yves
Very sad, when testing many horses, i failed, I rewrote the entire code, it worked, i retried again and it failed, because it wasn’t optimized enough, even tho I didn’t change a single thing. It seems that the fact if the code is optimized enough depends on the server usage which sucks a lot…
There can be fluctuations of performances server-side, but that will not change your code. If it is optimized it will stay optimized no matter the server.
On this puzzle an optimized code can pass all tests widely below the time limit, so perhaps you don’t have the good method…
Salut, j’ai fait mon code en classant par ordre croissant puis en regardant chaque différence des nombres cote à cote . Tous les test marchent sauf le premier, voici mon code:
Code removed by moderator.
Pouvez vous m’expliquer ou sont mes erreurs merci.
Please post in english and don’t share (nearly) functional code. Precise your problem, and post excerpts if needed.
If you call d_0, d_1, d_2, … the differences you want to compare, your list difference looks like this:
[d_0, d_0, d_1, …, d_n-3]
instead of:
[d_0, d_1, d_2, …, d_n-2].
Also, note that instead of sorting and displaying the element of index 0, you can use the min function.
Hello everyone,
I passed every tests but i’m blocked at 90% the diff between 2 horses seems bugged if someone can send me his solution it would be nice.
I can send my code to proove that i passed it ofc.
Thx guys.
Hey.
If you pass every tests but not the validators, there is only one possible reason: Your code does not work on every possible case.
No bugs involved on the puzzle side. (And nobody will send you his solution of course, that’s not the spirit…)
Drat… I was so proud of myself. I wrote my first merge_sort function (from scratch without looking at example code), but it was too slow for disorder. Oh well, it was a good learning exercise.
Hello there! Javascript user here
This has been the first puzzel since years and I’ve some troubles, and no other code to compare my solution to.
I’ve tried two tactics to solve this game. My first solution was to start by building the array, than use the js .sort() function so the numbers are in the correct order and than compare every number to the previous one to find the closest difference. This worked well, but I only got a score of 90% as I didn’t pass one validator.
Than I’ve tried to put all the previous steps directly in the readline loop. This worked flawless, but for some reason I get a Failure Process has timed out. on Test Case 3 Many Horses.
Can somebody please show me my mistake? I appreciate your reply!
Code removed by a moderator. //Please do not share complete code.
@pascal-Case, when a moderator delete your code, saying you to not share complete code, you don’t put that code back.
This is a warning, I strongly advise you to not ignore it.
If you want help, detail your problem, and if needed, share an excerpt of your code. If then someone, ask you to share your complete code to him to help you, use privates messages.
I found why I was failing at the “Horses in disorder” even though I was following all the advice here.
I was setting my answer value to 0 by default. This meant when I came across two horses of the same strength, the answer became 0 because the smallest difference was 0… which meant whatever the next difference was became my new answer, because my code thought that 0 was the default which needed replacing.
J’aimerai bien savoir aussi ! j’ai le même problème
I’m Using C# I use List Then Sort the minus first tow element from Array But it seem There is Bug
Hello all, I couldn’t pass the test for Horses in disorder, below is my code, please help! My code is in c++
Code removed by a moderator
That initial_smallest variable seems completely unnecessary, but the main problem is here:
This doesn’t make any sense, should probably be:
smallest = 0;
Also, you shouldn’t post (almost) working code here - you can edit your post to remove it.