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.
Oh yeah, true.
The case I was surprised there was no test for was
1 + x + 2
should simplify tox + 3
, but I definitely had fun regardlessNo, 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.For point 2, the problem description should be clear which associativity to use, even if both left and right are mathematically correct. If this is not the case, please raise an issue.
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
These should all (besides random tests) be fixed now thanks to mjpeters' fork. (?) Please open new issues for any new problems found.
Approved
In the description we have that
but then nowhere we have a description that program is just one function.
I think either adding
program ::= function
to the grammar, or saying that testcases will be valid functions would save me quite some confusion and probably few minutes.I've re-written the Rust translation, to address a number of issues:
Please approve!
I've created a fork that addresses all of these issues except for the randomised tests, since none of the other translations have randomised tests either.
And another issue:
Seemed like the fixed tests either got added or removed some time ago, because I saw all languages have unified fixed test cases now, would have to check and verify it again later ^^
Description can & should be made language agnostic.
Sorry, which testcase is it that should be added?
I'm fixing the Ruby version.
Nice kata, good if you want to learn about closures
Loading more items...