The constraints are confusing in the French version for the larger dataset
Is it actually 10 to the ninth power ?
âContraintes
Pi †L
1 †L †109
1 †C †108
1 †N †10000
1 †Pi †107â
The constraints are confusing in the French version for the larger dataset
Is it actually 10 to the ninth power ?
âContraintes
Pi †L
1 †L †109
1 †C †108
1 †N †10000
1 †Pi †107â
Same on English version:
1 †L †109
1 †C †108
Incorrect game conditions, because:
Constraints
Pi †L
1 †L †109
1 †C †108
1 †N †10000
1 †Pi †107
If so, you can not pass a some of tests.
But it is necessary to forget about the boundary conditions, and immediately passes all the tests, except for the last.
Itâs bug?
[English]
Hello, I just perform this puzzle with clojure, but I previously didnât know this language. Because I am a beginner is this language, I am not proud of my code and I think that I didnât used the potential of Clojure. Could you give me some advices?
For example, how did you store input datas? I have used:
(def groups [])
(loop[i N]
âŠ
(def groups (conj groups Pi)) ; add âPiâ to vector âgroupsâ
âŠ
I imagine that there is a better way to create it (recursively?), but I have not been able to do itâŠ
[French]
Bonjour, je viens de terminer ce puzzle en Clojure, mais câest un langage que je ne connaissais pas auparavant. Parce que je suis dĂ©butant dans ce langage, je ne suis pas fier de mon code et je pense que je nâai pas utilisĂ© le potentiel de Clojure. Est-ce quâil serait possible dâavoir quelques conseils ?
Par exemple, comment stocker proprement les donnĂ©es initiales? Jâai fait ainsi :
(def groups [])
(loop[i N]
âŠ
(def groups (conj groups Pi)) ; add âPiâ to vector âgroupsâ
Jâimagine quâil y a un meilleur moyen pour crĂ©er le vector âgroupsâ (recursivement ?) mais je nâai pas trouvĂ© comment faire⊠Un conseil ?
Thank you very much.
Salut alberola,
DĂ©solĂ© de tâennuyer mais si je me baladais sur le forum car quelque chose dâĂ©trange (ou en tout cas qui me semblait Ă©trange) se passait avec mon code et je suis tombĂ© sur ton post. Je crois que toi appliquons plus ou moins la mĂȘme idĂ©e. Je passe les tests jusquâau dernier oĂč jâai une valeur fausse dâenviron 15%. Je trouve cela vraiment Ă©tonnant car je nâai pas le sentiment que le dernier test rajoute quoi que ce soit au niveau de la logique du problĂšme, câest juste une instance beaucoup plus grosse. Sais-tu ce quâil se passe ? Merci
Jo-Yun
This find-the-loop trick actually brings the running time down to O(N).
Used this technique to solve in Python and Closure.
The Closure code is rather long (compared to 20 lines) and ugly, though.
Delete the debug messages - great advice
I couldnât pass the large dataset test with my prinErr code in JavaScript.
Hi,
I have not seen any message about Javascript, so here it is.
First I did like everyone with an array and add/substract functions in array, but it did not pass the last test because time execution. So I changed the algorithm by removing all push/splice/slice functions. Instead of removing the beginning of the queue, pushing it at the end of array, and calculating for next round, and I do not manipulate the array and let an index reading the array and going back to the beginning until I reach C rounds. It passes 100% with this approach.
I can olny complete the very large set but not the large set. My IDE has the correct solutions for all test cases.
Help?
Forget it. Already saw the error. Hmm, 180 lines of code is alot. I saw other playerâs solutions and I think i complicate it too much⊠Oh wellâŠ
En deux mots : dynamic programming.
Thanks for the hint !
My first solution was a naive FIFO queue, i then changed it to a simple array with start/end pointers, and i still couldnât get the last test in time.
Memoization for the win \o/
Well, I solved it in C#, and I canât really say thatâs a Hard puzzle, you just need some caching and thatâs all.
But the thing is I saw many published solutions without the memorization/cache, and my question is:
How did they pass the tests?!?!?!?!?!?!?!
I even copy/pasted some of these solutions and in my IDE all and every one of them without the caching fails at the last test (I must say I didnât try to submit it, just testing in IDE).
So, how did these solutions pass the validators?
This was a good one! My first attempt was a simple brute force solution, no dice obviously. Then I memoized it. Still not quite fast enough. Then I noticed that âdynamic programmingâ was mentioned in the briefing, so I studied a little and discovered a smart way of solving this. In the end I was able to solve test case 6 under 0.02 seconds and got 100% (python 3).
Very useful exercise, thank you!
Personnellement, jâai rĂ©solu ce challenge grĂące Ă cet algorithme:
Je peux ainsi résoudre le dernier test unitaire en à peine 6ms.
Bonne chance!
I Agree with the analysis. And then there are the half-way caching solutions that are passing the tests. I tested in CG IDE one highly-voted 30-line C-language solution that looped C times, and it found the answer to the large dataset in 50000 clock ticks. My solution detects the loop and then calculates the costs for the pre-loop, the loops and the post-loop. This is about 100 lines of code. It does the large dataset in 35 clock ticks, yelding to 1400-fold difference. Maybe the provided solution testing times are bit too lax or the datasets are too smallâŠ
Il suffit de le coder naivement en javascript
Je suis trĂšs intriguĂ© par la mĂ©thode dâĂ©valuation des algo, je mâexplique :
Bref, je pense quâil faut utiliser la mĂ©thode de la tortue et du liĂšvre pour le faire âcorrectementâ en python ou clojure mais en javascript câest cadeaux et de niveau âfacileâ
What is the challenge at the Validator 9: âWorks with a large datasetâ?
My code runs in 2ms for all the test cases. (Obs.: 40ms to read data, and 2ms to solve).
I passed at the Validator 10: âWorks with a very large datasetâ, that is more complex, but didnât pass at 9. Anyone has any clue?
I already change everything to long, so, it is not overflow.
Iâm coding in Java.
Maybe you are overflowing round repetition? Honestly I donât think it is possible. But itâs the only thing that came to my mind