Ad
  • Custom User Avatar

    Fixed

  • Custom User Avatar

    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'].

  • Custom User Avatar

    Traceback:
    in
    NameError: name 'Alphabet' is not defined

    For python, I cannot run the tests.

  • Custom User Avatar

    @nklein: making it clear on the description the expected order of operations should solve this issue.

  • Custom User Avatar

    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.

  • Custom User Avatar

    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.

  • Custom User Avatar

    I've learned a lot ! thank you @nklein for this very very good Kata :)

  • Custom User Avatar

    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}}}}}

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    I didn't quite where does the ideam sum/ ideal product comes from?