Ad
  • Custom User Avatar
    Can solve {"op":"~","inner":{"op":"*","left":40,"right":{"op":"~","inner":{"op":"~","inner":{"op":"~","inner":{"op":"~","inner":4}}}}}} without throwing
    
    Returns a list of instructions which contains the minimum viable items
    
    expected [Function] to not throw an error but 'AssertionError: Result is too short: expected 1 to be at least 6' was thrown
    

    Result is too short is clearly not what minimum viable items, as stated by the test block, means, so it's just plain confusing. It's also a very roundabout and kinda unreliable way of testing the actual requirement of not folding constants.

    If you want to check constants are not folded, you'd at least need to reconstruct the AST and check if they're structurally equal. That's the only way.

  • Custom User Avatar

    Thanks! Fixed now

  • Custom User Avatar

    Fixed, only generateTestCase and deepCopy are exposed now.

  • Custom User Avatar

    isInfix was changed after the reference solution was changed.

    But there are still things other than generateTestCase that's leaking to user code space, such as infixOps and unaryOps. These things should be IIFE'd.

  • Custom User Avatar

    I'm not sure as to how I should do this with an IIFE - I need to access for example generateTestCase multiple times within the test script.
    Could you give me an example as to how I could solve this with iffys?

  • Custom User Avatar

    Should be fixed now

  • Custom User Avatar

    Reopened: (Initially posten by Voile)

    If user has defined isInFix themselves they'll get SyntaxError: Identifier 'isInfix' has already been declared.
    Should use an IIFE to isolate your preloaded helper functions so they don't pollute the user code scope.

  • Custom User Avatar

    Thank you very much for pointing this stuff out!
    Fixed both of the last two bullets, but I can't reproduce the first one just yet

  • Custom User Avatar

    Funky stuff are happening to the tests at the moment:

    • Actual tests: sometimes ERROR: expectedSumAst is NaN but expectedSum is NaN! Our solution is wrong! is thrown inside test code and the test fails
    • Also sometimes Infinity is expected there
    • Sample tests: .replaceAll is used by it's only supported by Node v15+; CW environment is Node v14 so it's throwing an error
  • Custom User Avatar

    Now if user has defined isInFix themselves they'll get SyntaxError: Identifier 'isInfix' has already been declared.

    You should use an IIFE to isolate your preloaded helper functions so they don't pollute the user code scope.

  • Custom User Avatar

    Should be fixed now

  • Custom User Avatar

    It allows for more solutions to the kata. One solution may contain more expressions, but turn out to be the same answer.

  • Custom User Avatar

    You were right, I've modified my solution based on yours.
    Btw:

      { op: '~', inner: 't0', out: 't0' },
                         ~~ Should be 'xy'
    
  • Custom User Avatar
    [
      { op: '+', left: 'x', right: 10, out: 'test' },
      { op: '~', inner: 't0', out: 't0' },
      { op: '+', left: 'xy', right: 20, out: 't1' },
      { op: '-', left: 't1', right: 'x', out: 't1' },
      { op: '/', left: 't0', right: 't1', out: 't0' },
      { op: '+', left: 'test', right: 't0', out: 'test' },
      { op: '+', left: 'test', right: 10, out: 'test' }
    ]
    
  • Custom User Avatar

    Right. Could you show me this example solution which only uses two temporary variables?

  • Loading more items...