I finally optimized for the final test case, and found that in Java, creating an ArrayList, then sorting it, before moving on works the best. Because then you just have to compare adjacent elements, rather than the whole collection of elements.
Simple solution in java (100%): I was surprised it passed the last one actually
[nope}
i dont get it, when i console.log(N) it just give a numberā¦
and pi give me an error?!?! so where do we get the list of different strength?
Please refer to the default code for how to read the inputs and how to debug (print to error stream).
Hey. ^^
Is the PHP āsortā function not accepted in the āHorses in disorderā test submission? Because all others tests work correctly except this one (and implementation of others sort methods are too slow for the IDE third test)ā¦
My PHP code which solves the puzzle uses the āsortā function, so I guess the issue is not related to that function. Could there be some other issues with your code?
Thanks for your answer, but I just found the ābugā with the expert mode. Well, this one was tricky. x)
Hi! I actually donāt understand what the āHorses in disorderā mean, we donāt have any I/O for that one. I assume from your comment, that there can be horses with equal strength, but I actually ādeleteā or replace their position on the array to avoid this issue. But I still canāt pass the test. Any advice?
La variable Pi nāaffiche aucun int dans le terminal, lāIDE bug ou bien cāest normal ?
you should not ignore horses with the same strength
Think about that statement for a second. If youāre supposed to find the horses with the closest strength to each other, and you have two who are equal, and youāre intentionally excluding one of them from the searchā¦ finish that thought.
I did 90%
But I canāt understand in any way! What do you mean āall horses tieā?!
The previous replies may help you:
https://forum.codingame.com/t/horse-racing-duals-puzzle-discussion/38/313
https://forum.codingame.com/t/horse-racing-duals-puzzle-discussion/38/316
Thanks for the answer!
But, unfortunately, these tips did not make clear the understanding of what they specifically want from me. I tried to add an algorithm that removes duplicates, but the result has not changed.
Does your code output 0 if the horse strengths are 3, 3 and 3?
Yes it is! Only if absolutely all horses are the same.
Upd: Ok, I fixed her! āAll horses tieā - done
But but now āHorses in disorderā does not pass the test
itās crazy, but itās fun!
I used a set data type for my first time, c++, and it took care of my code timing out on the big lists. By using a set you can can insert the numbers as you get them, and it inserts the new number in the correct position, thus eliminating processing time of sorting after getting the input.
Hi everyone,
Same as many people, I have 90%, and I donāt know why āHorses in disorderā doesnāt pass, I use Collections.sort() on an ArrayList,
thx for your help
Did you read the discussion in this thread? Some of it may be helpful to you.
La mĆŖme pour moi. Je passe les tests ide, mais pas les validateurs. Je pense que mon souci est du aux chevaux ayant une puissance Ć©gale.