Ad
  • Custom User Avatar

    i have run the simulation step-by-step for this test case and the expected answer is correct. the final state is (with head at H, going leftwards and hence colliding):

    -----------$--$----$-
    --$-------$-$$------$
    $----$$-$--$-$-$--$--
    $---$--$-----$-------
    -$$$---$----$$$--$---
    $--$$---$----$$-$-$--
    -$--$$$--oHoo$-$-----
    $---$----oooo--------
    -----$-------$-$$--$$
    -$$-$---$-$-$$$--$-$-
    -$$----$-$$----$-$$-$
    $--$-$---$-$-----$-$$
    -$$$---$-----$$$----$
    
  • Custom User Avatar

    I think your code must get lost in some infinite loop cause I don't think you may exceed the maximum recursion limit with a reasonnable code here. Hard to help you without more elements

  • Custom User Avatar

    @squishy oranges, what do you mean do the summation directly? A double for loop doesnt work for me either. I've tried condensing one of them using sum() and the for loop as a one liner but it still times out.

  • Custom User Avatar

    I'm having trouble with this one. I'm just using the standard dot product algorithm and I always exceed the time limit. When I use recursion, I exceed the max recursion rate and I can't import sys to increase it. I don't understand how to make this faster.

  • Custom User Avatar

    The recently included test case that verifies food is only consumed once is causing a contradiction with other test cases.

    Some tests assume food remains in the field after being eaten so this Kata is no longer solvable.

    Example:

    moves = '7 D 7 R 3 U 1 L 7 U 6 L 1 U 5 L 6 D 3 L 8 U 6 L 2 U 3 R 1 D 5 R 5 D 4 R 4 U 7 R 2 D 4 R 7 U 8 R 4 D'

         field = ['ooo-$----$-$--$----$-',
                  '--$-------$-$$------$',
                  '$----$$-$--$-$-$--$--',
                  '$---$--$-----$-------',
                  '-$$$---$----$$$--$---',
                  '$--$$---$----$$-$-$--',
                  '-$--$$$--$$--$-$-----',
                  '$---$------$---------',
                  '-----$-------$-$$--$$',
                  '-$$-$---$-$-$$$--$-$-',
                  '-$$----$-$$----$-$$-$',
                  '$--$-$---$-$-----$-$$',
                  '-$$$---$-----$$$----$']
    

    The test says ((0, 4), 33) should equal ((6, 10), 21) but this could only be true if the snake ate the same food twice and was long enough to collide with itself.

    I've found a few other scenarios like this.

  • Custom User Avatar

    "Brilliant?" Are you UK-based too?

    Anyway, thanks :)

  • Custom User Avatar