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.
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!
yes ("work" as in "you can run it". But there are problems with the tests, yes)
.
@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):
If this doesn't answer your question, you'll need to provide a more clear description of your scenario.
"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?
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.
Thanks, approved :)
@Jomo: Click "Add New" and it's right there.
Make a comment with a link to it, please.
@gdbaldw
, thanks for the edge case suggestions. I've added them to both Python and JavaScript translations. 👍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 gemEDIT: 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.
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.
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
Python translation is published, awaiting approval
'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...