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.
No, it's honestly fine I think. All the test cases are associative towards the right anyway, i.e.
a*b*c
is treated asa*(b*c)
. Same for plus.after taking a break from codewars for a few months, it feels great to solve a difficult question in only a few hours. So, it's either I've gotten way better or this kata was a little bit easy for 1kyu. It's probably the latter, realistically speaking though- lol.
Anyway, this was a great kata- I've never written a compiler before, and this kata really helped me understand how they work. Some suggestions:
The
pass2
constraints are very lenient. As mentioned also by someone else in the comments,pass2
should also remove unnecessary+0s
,*1s
, etc. (i.e.pass2({'op': '+', 'a': {'op': 'arg', 'n': 0}, 'b': 0}
should return{'op': 'arg', 'n': 0}
)Some "different" solutions are the same, algebraically, because operations like adding and multiplying are associative. The test suite should let these solutions pass too. I know, an infinite number of solutions now are possible, but it would be nice to have some leeway.
-goldenratio161
you know, when I figured out the solution, I went, "ohhh, so that's why it has to be prime!"
nice kata.
approved by someone
Python:
passing all fixed test cases but no random test cases. Although it is probably because of my terribly-written, bug-riddled code, the random tests are impossible to debug. The strings are way too long, and it would be really helpful if there were some shorter random strings.
ah, that's annoying; must be an off-by-one error i guess.
haha lol, its just that when seeing "There is no solution to show" pop up, I thought you had already given up on this kata.
two years late, but you and I had the exact same issue. there is a way to solve it though; think of how you would solve this on a square grid, and notice what the algorithm behind it actually does to each individual piece.
my first 1kyu kata solved! this was an amazing kata, spent damn near 2 weeks on this, but it was really worth it. thank you, jaybruce, for making this; that's 83 people very satisfied with this kata now :)
oh wait, I've figured it out!
the test cases sort a list of
PokerHand
classes, and you need to sort them based on the hand value.ah crap, I actually don't understand it too; I pass example test cases but the random test cases just say "failed at test n".
I'm confused, what?
This comment is hidden because it contains spoiler information about the solution
oh shit, my bad, I forgot to add it
This comment is hidden because it contains spoiler information about the solution
I must say, that was quite a bit harder than i expected it to be. Really fun to solve though!
Loading more items...