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.
Shouldn't the sequence start with two of the highest values in your memoization container instead of (1,1)?
Frankly, all solutions here I saw but for 54d7ac's one (mathematically optimal, but won't scale to big integers, transformation matrix is better for that, although brings O(log(n)) instead of O(1)) are heavily suboptimal anyway so it depends what you aim for. ;) I aimed for Iterator approach.
Overkill
This comment is hidden because it contains spoiler information about the solution
There is a problem with Nim tests that is difficult to see.
Tests can be green with "Passed etc..." even if some fail.
Look if there is a small orange rectangle near "Tests results", in that case at least one test have failed.
I reported the bug at CW. Please see https://github.com/Codewars/codewars.com/issues/1087.
Complete this bug report by your observation. That could hopefully speed up a fix to that.
Sorry for the inconvenience.
Cheating, it doesn't work for any m >= 200. :-/
My solution in Nim passes all the tests but, oddly, the button doesn't change to Submit Final.
Just like you use
div
operator, usemod
. It's much more natural than unsigned-mod%%
operator.Many thanks for your contribution; reviewed and approved :D
Thanks. By the way, if you have any suggestions to improve Nim support on Codewars, please let me know by opening an issue on Codewars/codewars-runner-cli.
x.toInt
does the same asround(x).int
but is shorter and (probably) more efficient.Use
a div b
for integer division, notint(a / b)
.Probably better than my own little obsession, namely: "I know it already passes tests but I can make it better composed/more general/nicer to read". ;)
:D Why do more when you can do the same with less? (Don't answer that...I know the correct answer)
I felt it's a bit un-pytonish to actually add methods to an existing class without no real reason.
Loading more items...