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.
Lua translation!
This comment is hidden because it contains spoiler information about the solution
yes it is, here are docs with a great breakdown https://docs.codewars.com/gamification/ranks/
Because the first 9 chars expected to be digits
too many edge cases for this during testing.
great problem!
Would love to see a follow up problem to this one maybe something like getting assembly (or some kind of bytecode) as input and the goal is to produce a readable expression like:
input:
AR 0 SW IM 2 MU SW IM 1 SU
output:
[a] 1-a*2
(this wouldn't be a 1kyu problem but it would be fun :) )
Cool kata! It feels like a real world problem.
I hit that mine too with my first implementation of pass1(), and was a little frustrated that the tree wasn't accepted and I had to refactor.
That said, and to be fair, the grammar for expression and term does define the order the tree should be built in, altough it could be a nice gesture to explicitly state the associativity in the description too.
But your tree does not seem to conform to the associativity described with the grammar syntax? The grammar does not allow for
expression
on the right.Honestly pretty disappointed that the tests only accept a certian tree for
pass1
. I really like the way I implemented it with the tree going the other way but now I have to refactor everything to get it going the other way and I'm having a really tough time of it.for example
1+2+3+4
right:
Add (Add (Add (Imm 1) (Imm 2)) (Imm 3)) (Imm 4)
wrong:
Add (Imm 1) (Add (Imm 2) (Add (Imm 3) (Imm 4)))
Very nice kata! Even though it is a very simplistic language, it is cool to have actually witten a (simple, but real) compiler.
It would have been nice to have the Ast classes (C#) provided just like the simulator to easily be able to play with it in your own dev environment (they were easy enough to recreate, but still).
ok thanks
Do you understand that you're comparing NESTING STRUCTURE, right? Read the description again if not. You're not comparing data types.
It doesn't say anything about each element datatype matching. You can think of the list elements like list and not a list (it doesn't matter which datatype is) if you want.
not the same INT is not equal STR.
The nesting structure is the same, not a kata issue. The data type doesn't matter, unless it is a list, because they can be nested, unlike the other data types.
Loading more items...