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.
Almost did the same thing...but I changed the trait bounds on
array_diff
to also require thatT
implement theCopy
trait.Then I used
iter
andcopied
instead of just usinginto_iter
like I should have...because I initially misspelledinto_iter
while trying this exact thing :Pcheck this
This comment is hidden because it contains spoiler information about the solution
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 :(That was a clever one!
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....
This comment is hidden because it contains spoiler information about the solution
Loading more items...