Ad
  • Custom User Avatar

    Anyone know if applicative parsers are possible to do in Ocaml? (I know monadic ones can be done). I made an attempt at a translation, but Ocaml complains

    Error: This kind of expression is not allowed as right-hand side of `let rec'
    

    when I try to actually use the mutually recursive functions I wrote in my Haskell version (exprP, binP, etc). I'm not sure if I'm doing something wrong or if this is a limitation of the language, I would appreciate it if anyone can take a look at my translation.

  • Custom User Avatar

    My solution passes all the test cases but gives the error:

    does not cheat
         scanl is not used
    

    All of my answers were one line calls to scanl so I'm not sure what it's upset about. It possible to fix this one? It's a pretty fun problem.

  • Custom User Avatar

    The tests are correct.

    populate() method gets called and right after that test checks print_state() and expects 12 elements instead of 8. How count of elements may change without calling the move(), or how it can increase even with move()?

    Note the last few bullet points on the instructions:

    This method may be called multiple times on the same class instance

    If a new blob's position is already occupied by an existing blob, the two fuse into a single blob

    In the test case generation 1 has already been populated. Notice that the state of the board just before populate(generation2) gets called.

    blobs = Blobservation(10,8)
    blobs.populate(generation1)
    blobs.move()
    pf(blobs,[[0,6,1],[1,1,1],[1,6,2],[2,1,5],[2,6,7],[4,2,6],[6,7,3],[7,1,2],[7,4,4],[7,7,1],[8,7,3]])
    blobs.move(2)
    pf(blobs,[[0,6,7],[1,5,3],[2,2,6],[4,1,6],[6,1,2],[6,4,4],[6,6,7]])
    blobs.move(2)
    pf(blobs,[[2,4,13],[3,3,3],[6,1,8],[6,2,4],[6,4,7]])
    blobs.populate(generation2)
    
  • Custom User Avatar

    Relative to the blob (12 o clock is always up).

  • Custom User Avatar

    "every blob whose size is larger than the smallest blob size value will move to one of the 8 spaces immediately surrounding it in the direction of the nearest target blob with a lower relative size."

  • Custom User Avatar

    Ok, I'll keep working on it. I'm up to 312.

    It does seem strange that if the number of tests (and presumably the variables in each) are random that I'd successfully complete the same number most of the time though.

    Edit: Nevermind, I figured it out. Good kata!

  • Custom User Avatar

    Python 3. I tried changing my board from a dictionary to a list of lists instead but I still get the same result.

  • Custom User Avatar

    When I add a print statement to the top of move it either still times out or I get this result:

    Full Test Suite
    PRELIMINARY TESTS
    FIXED TESTS (38 of 38 Assertions)
    RANDOM TESTS (259 of 259 Assertions)
    STDERR
    Execution Timed Out (12000 ms)

    Is it just too slow?

  • Custom User Avatar

    Hi, my code runs fine on the sample tests and the first part of the assertions, but fails on the random tests. Initially it was crashing in a few places (I'm guessing when trying to call move() with no blobs), but now my code just times out when I try to sumbit which makes debugging difficult. Any hints on how to procede?

  • Custom User Avatar

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

  • Custom User Avatar

    Thanks, it works now.

  • Custom User Avatar

    I don't see any difference in the description, but I changed my code to return an array and now it times out some time after sum_john 99.

  • Custom User Avatar

    I must have missed the part in the description where it said that only arrays and not lists would be acceptable.

  • Custom User Avatar

    In OCaml, I get the expected result when run localy, but when attempting to run the sample tests I get the error:

    File "(stdin)", line 49, characters 23-26: Error: This expression has type int list but an expression was expected of type int array

    Line 49 is beyond my code (20 lines).

  • Custom User Avatar

    I think the issue is that the kata explicity mentions the naive forumla for calculating nCr, but doesn't make any mention of the fact that opimizations are required to actually run on larger inputs. I think this is a harder than 6kyu problem for that reason.

  • Loading more items...