Ad
  • Custom User Avatar

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

  • Custom User Avatar

    Yes, thank you!

  • Custom User Avatar

    The "should it merge?" function expects 3 arguments:

    Shouldn't this say 1 argument?

  • Custom User Avatar

    The model solutions returns False for is_factorable([7, 6, 3, 0]), yet

    $x^7 + x^6 + x^3 + 1 = (x + 1)(x^6 + x^2 - x + 1)$.

  • Custom User Avatar

    My fault, I think I have corrected the solution now.

  • Custom User Avatar

    Thank you! I've modified the test to have fun g (f, x) = f (x, x).

  • Custom User Avatar

    In sample tests "shadowing" you have this test:

    invalid(`
      fun f (a, b) = a
      fun g (f, g) = f (a, b)
    
      out f`, "The parameter identifier 'f' overrides the global function 'f'");
    

    However, this is also invalid due to a and b being unbound variables. This means the test can be passed without actually handling the shadowing case properly. I suggest a slight modification:

    fun g (f, g) = f (f, g)
    
  • Custom User Avatar

    I'm not sure why the test case $x^{1000000} + 1$ gives false. It can be factored as $(y + 1)(y^{125624} - y^{125623} + y^{125622} - ... + 1)$, where $y = x^{64}$, can't it?

  • Custom User Avatar

    Thank you for the additional tests: I think that your first program never terminates though, so I modified it to

    fun f(a, b) = b + if a < 0 then 0 else if a > 2 then a + b + f(a - 2, b + 1) else 3 + f(a - 1, b + 3)
    out f
    

    I've added that modified version and the other two tests you suggested.

  • Custom User Avatar

    A very enjoyable kata! One thing which I found challenging is handling conditional expressions. However, the current tests are not comprehensive enough. I suggest adding the following test cases:

    1. Calls inside conditional branches which are not in tail positions:
    fun f(a, b) = b + if a > 2 then f(a - 2, b + 1) else 3 + f(a - 1, b + 3)
    out f
    
    1. Calls inside the condition expression:
    fun f(a) = if hd [g(a), 3] = a then a + 3 else f(a - 1)
    fun g(x) = if x < 4 then x else x + 1
    out f
    
    1. A Fibonacci variation (the sequence starts from 1, 1) which combines 1 and 2:
    fun fib (n) =
        (if n > hd [1, if n = 0 then 3 else fib(n - 1)] then fib(n - 2) else 0) + 
        (if n > 0 then fib(n - 1) else 1)
    
    out fib
    
  • Custom User Avatar

    Yes :)

  • Custom User Avatar

    At least for sample tests, whe invalid is expected, is it possible to provide an error message stating why it should be invalid?

  • Custom User Avatar

    The syntax you described isn't strictly correct EBNF, but I appreciate the effort-it's still comprehensive and clearly presented.

  • Custom User Avatar

    Yes - some of the input programs, for example gcd, already has all of its calls in tail position, and a lot of tests are assert.doesNotThrow for checking that you haven't missed any cases for constructs in your parsing code.

  • Custom User Avatar

    Is it expected around 25% of tests pass if I just submit the initial code?

  • Loading more items...