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.
Fixed
Seconding this. In the default python tests, Alphabet is a dict but it's treated like an object. Alphabet.TYPE should be changed to Alphabet['TYPE'].
Traceback:
in
NameError: name 'Alphabet' is not defined
For python, I cannot run the tests.
@nklein: making it clear on the description the expected order of operations should solve this issue.
I agree that your solution works in this case. If, however, all of the '+' signs had been '-' signs, your parse tree would have to have a different shape. Did you really code '+' to be right associative and happen to still get '-' as left associative?
I was going to change the test case to make it explicit, but I don't have time to get it right today. So, I'll just say this... the parse tree shown above does not agree with the BNF in the description. The BNF says that an expression is a term or an expression '+' a term or an expression '-' a term. It doesn't say that it can be a term '+' an expression.
Indeed. I have a solution which generates a valid pass1, I believe a valid pass2, and a proper pass3, but I can't submit because this first test-case is too strict.
I've learned a lot ! thank you @nklein for this very very good Kata :)
I think there's a bug on the test case.
For:
[ x y z ] ( 23x + 5y - 3z ) / (1 + 3 + 2*2)
This is also valid for pass1:
{"op":"/","a":{"op":"+","a":{"op":"","a":{"op":"imm","n":2},"b":{"op":"","a":{"op":"imm","n":3},"b":{"op":"arg","n":0}}},"b":{"op":"-","a":{"op":"","a":{"op":"imm","n":5},"b":{"op":"arg","n":1}},"b":{"op":"","a":{"op":"imm","n":3},"b":{"op":"arg","n":2}}}},"b":{"op":"+","a":{"op":"imm","n":1},"b":{"op":"+","a":{"op":"imm","n":3},"b":{"op":"*","a":{"op":"imm","n":2},"b":{"op":"imm","n":2}}}}}
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
I didn't quite where does the ideam sum/ ideal product comes from?