Ad
  • Default User Avatar

    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.

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    In Rust, the description doesn't say the returned list needs to be in ascending order, but tests fail if it's not.

  • Default User Avatar

    Upvoted for the single pass with early return algorithm :)

  • Default User Avatar

    You can get rid of that awkward Ord::cmp() call by replacing .sorted_by with .sorted_by_key.

  • Default User Avatar

    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.

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    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 :(

  • Default User Avatar

    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.

  • Default User Avatar

    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....

  • Default User Avatar

    I love this!! It makes me think of a squirrel eating a slice of bread :)

  • Default User Avatar

    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:

    With n = 9103, k = 5
    Expected (16, 1039, 3947) but got (15, 1097, 3947)
    

    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.

  • Default User Avatar

    Weird flex but okay :)

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar
  • Loading more items...