Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
This problem is way more strictly mathematical in fact and requires some generalization based on research indeed.
see issue above
I liked the kata but I agree, this part about always having a direction even when no keys are pressed at all and therefore there is no movement is weird. An invalid/uninitialized direction like e.g.
-1
or0
would have made the API clearer. The defaultUP
direction does not make much sense either.I rarely say bad things about a kata, but this one was confusing in Java.
My main problem was that my direction always should be something of 2/4/6/8, it is constantly tested, just as my initial direction as 8. But at the same time if the player presses 8, I cannot start moving into that direction, even though basically I was facing that direction already. I let that go, because initial state and stuff.
But then random tests started failing, because apparently if every key is released, I should "lose" my direction (well, obviously not actually lose it, because the tests will still test it, there was a rule that I should not change direction if nothing is pressed). But then once again, I am facing a direction, and if that key is pressed, i should not start moving, but should face into that direction even more. I mean I could figure it out, but I think the rules of this game are a bit unclear.
Even if you do not accept something like direction -1 for "rest state" (just from the top of my head), it could be clarified in the rules, that even if you technically face a direction at the beginning of the game and after all keys were relesed, you should never start moving instantly. Technically rule #2 implies something like you should never start moving before the second iteration of a key being pressed, but the first rule implies that you should not start moving because you should first change your direction.
Still gave it a Somewhat though, the idea is really cool.
Not gonna lie, I postponed solving this one for a long time, because I always felt this is gonna be so hard and complicated, my code will time out etc. Finally started to actually code it, it was fun and it took me no more than 3 hours to pass all tests, so yeah... I was wrong.
Do not let the description or the unusual problem discourage you, it is a really cool one! Do not be like me, give it a try!
both fixed
What's mean for Python?
Time: 10865ms Passed: 10 Failed: 0 Exit Code: 137 and not about buffer or stderr or etc.
But kata is not marked as solved.
What should I do?
Thank you for your hard work!
JavaScript translation
I just did, and it passed!! What a great Kata!!
Suffered, but learned a bit,
And asusual, some Awesome code are already in the solution page,
some i understand, and some i don't.
Alhamdulillah!! Thanks You Madjosz!!!
It's just how you calculate your sum.
Fraction
is too inefficient. Get rid of it and your solution passes.Edit: Ok, reading Discord indeed floating point calculation were your prior problem, since they can store up to 16 digits exactly.
can there be problem after 16th or 17th digits? i dont understand??!! Anyone help?
I did exactly that, O(1) for one prime and using inclusion-exclusion means that I have to do that binom(n, k) times for 1 <= k <= n.
I pass 6 out of 6 30 digits tests but then my code times out. Am I still missing something?
great, just solved it, thanks for the motivational speech ;)
Loading more items...