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.
It's funny how so few people have completed this kata when the description spells out the algorithm for you. I guess people find the math jargon intimidating and run away.
This comment is hidden because it contains spoiler information about the solution
In Rust, the description doesn't say the returned list needs to be in ascending order, but tests fail if it's not.
Upvoted for the single pass with early return algorithm :)
You can get rid of that awkward
Ord::cmp()
call by replacing.sorted_by
with.sorted_by_key
.Nice! You could make it more efficient by replacing
.filter
with.take_while
since once you hit a score below 60 you know the rest of the scores are going to be below 60 too.This comment is hidden because it contains spoiler information about the solution
This kata is an opportunity to raise awareness for the constant Tau, symbolized by T, which is equal to 2π. It's a nice constant. There are T radians in a circle. See? Very elegant.
It might already be handily defined right alongside PI in your programming language of choice. It is in Rust, for example, though sadly almost all the Rust solutions are using
2.0 * PI
instead :(I tried this approach, but it started giving wrong answers somewhere between n=60 and n=70. I was using powf() instead of powi(), so maybe that introduced too much floating point error.
I finally got it! This kata had been a thorn sticking in my side for at least a year now. I just couldn't seem to logic it out. Today I stopped thinking and just stared at the "cute" and "not cute" patterns in the test cases (after printing them out all pretty) and let my visual cortex ponder it for a bit.
Now, to go tackle that goddamned "What's the flag?" kata....
I love this!! It makes me think of a squirrel eating a slice of bread :)
Can confirm this issue in Rust. I was interpreting "below" as "strictly less than" and had a hard time figuring out why my solution was failing the tests. Then I noticed that the case it failed on had the upper limit as a permutation of one of the primes and that the test was counting that:
It sounds like it's the Rust test implementation that's wrong, not the Kata description, based on the fact that the JS version doesn't have this issue. So either the Rust test should be fixed...or maybe the Kata description should just be changed to call out the different expectation for Rust solutions.
Weird flex but okay :)
This comment is hidden because it contains spoiler information about the solution
Twinsies! LOL :)
Loading more items...