Ad
  • Custom User Avatar

    Sorry for the late reply. I more or less abandonded this kata. I couldn't approve this translataion anymore because of Codewars' overly strict, simplistic and rather annoying approach to translations: If there's even the tiniest problem with a translation, I can't approve it, but I also can't fix the problem. That's just so dumb and frustrating... :-(

    Anyway, I copied this translation and now published it. Thanks to everyone involved!

  • Custom User Avatar

    yes ("work" as in "you can run it". But there are problems with the tests, yes)

  • Custom User Avatar
  • Custom User Avatar

    @monstaber, in that scenario all affected gems (that get shattered) are proc'd during the same move.

    Also note in the Description (with added emphasis):

    Rainbow Gems are a rare type of special Gem that destroy all Gems that match the color of the Gem it lands on

    If this doesn't answer your question, you'll need to provide a more clear description of your scenario.

  • Custom User Avatar

    "Since the only time this would matter is when the gem color affected by the Rainbow Gem and Crash Gem are the same, it doesn't make a difference. The Rainbow Gem would destroy all gems of the respective color, including the Crash gem."

    Isn't it still possible that this makes a difference? What if there are gems of the same color not directly linked to the spot of the crash gem -- then, if the crash gem destroys all the local same-colored gems first and the rainbow one subsequently falls to the floor, the unconnected same-colored gems would remain; but if the rainbow is processed first, they would be removed. Or am I missing something?

  • Default User Avatar

    Please look at my solution of your problem in my fork.
    I reduced the running time by demanding only 20 million primes.
    In Python, 25 million are too much, because its reaching the limit, as you saw. That is because your solution is already the fastest code that I know about and I tested most of the Python solutions. The problem is that the primes are generated very fast, but most of the time is spent by calling next(stream), which is very slow in python. So your translation would make no sense, because it would pass the tests only sometimes. Also it would be way too hard to expect that people find the optimal solution. Now it works, completing in 8 to 9 seconds with your code, and in 9 to 10 seconds with my slightly suboptimal code. But my solution is hard enough to find, so level 2 kyu.

  • Custom User Avatar

    Thanks, approved :)

  • Custom User Avatar

    @Jomo: Click "Add New" and it's right there.

  • Custom User Avatar

    Make a comment with a link to it, please.

  • Custom User Avatar

    @gdbaldw, thanks for the edge case suggestions. I've added them to both Python and JavaScript translations. 👍

  • Custom User Avatar

    Thanks for bringing this up, @gdbaldw. The Description has been updated with the following note:

    > NOTE: In the case where both a Rainbow gem and a Crash gem land during the same move, the effects of the Rainbow gem occur before the Crash gem

    EDIT: Since the only time this would matter is when the gem color affected by the Rainbow Gem and Crash Gem are the same, it doesn't make a difference. The Rainbow Gem would destroy all gems of the respective color, including the Crash gem.

  • Custom User Avatar

    Yes, I had solved this Kata. My comment was designed to alert the Kata author that accepted solutions such as mine and others I have tested all occasionally fail the random tests. I did nothing more to isolate the corner cases.

  • Custom User Avatar

    Hi gdbaldw,

    Did you get anywhere with this?

    One thing I noticed in terms of the pattern of digits in the two solutions was that they each have a "backward L" shape within at least one district. In the case of the first solution it's in District 2, and in the second solution the backward-L appears within both District 2 and 3 (and arguably 4). By "backward L" I mean that the digits in the district move downward, and then to the left.

    When I was solving this Kata, the downwards-then-move-to-the-left was one of the last things I had to code for (as I was getting None even when a valid solution was available). My solution takes a somewhat "brute force" approach in that it first generates every possibility for what each district combination may look like (5 valid districts according to the rules) and then compares the pattern provided in the input with each generated potential solution to see if we get a "hit" of winning 3 districts.

    I can't (for unknown reasons!) see beyond the 5th line of your solution so I can't see if your code covers this backward-L scenario fully (not sure I'd understand the code even if I could see it!).

    cheers, Phil

  • Custom User Avatar

    Python translation is published, awaiting approval

  • Custom User Avatar

    'would be simpler on gitter. I sent you a message, so that we can exchange there (that's avoid to reveal the way the tests are done here, too)

  • Loading more items...