Ad
  • Custom User Avatar

    This is realy confusing formulation.
    If UDLR is just head rotation, without movements, than snake can rotate head to his neck and collide himself on next movement.

  • Default User Avatar

    It's a first impression. ;-)
    I find the 'find your way in a 2D-array' challenges usually quite tedious to code.
    Not really difficult, per se, but prone to bugs. At least for me.

  • Custom User Avatar

    Are you referring to the requirements to solve it? Then I disagree. It can be done in 20-30 LoC. In fact I got smacked over the head because I rated it a 6kyu kata :D

  • Custom User Avatar

    This was my bad for reading the description poorly. I thought that U U U was identical to U 3 - not the case.

  • Custom User Avatar

    Thanks guys! appreciate it!

  • Default User Avatar

    I was struggling with this too and then I figured out that when there's no number with the direction is considered as a head turn without movement, so you don't have to count the step.

  • Custom User Avatar

    Snake doesn't move when changing its direction. It seems this information was removed from the description during the rewrite.

  • Custom User Avatar

    Directions certainly changed but the snake didn't move...

    (U doesn't mean the snake moves Up one step)

  • Custom User Avatar

    Description asks for head position and N: Number of steps leading up to and including the collision

    There is a test case with these moves given: U R L D U R L D

    The first move leads to a collision against the top border of the board. However the test expects [[0, 2], 0] rather than [[0, 2], 1]

    Am I missing something or is this wrong?

  • Default User Avatar

    This looks like an awful lot of work for a 5kyu.

  • Custom User Avatar
  • Custom User Avatar
  • Custom User Avatar

    A test that looked something like this should do it:

    moves = "18 D 12 L 20 U 12 R 5"
    field = [
    'ooo$$$$$$$$$$$$$$$$$$',
    '--------------------$',
    '$-------------------$',
    '$-------------------$',
    '$-------------------$',
    '$-------------------$',
    '$-------------------$',
    '$-------------------$',
    '$-------------------$',
    '$-------------------$',
    '$-------------------$',
    '$-------------------$',
    '$$$$$$$$$$$$$$$$$$$$$'
    ]
    
    Expected: ((0, 5), 67)
    (snake can chase tail indefinitely around the field)
    Bad solution: ((0, 3), 66)
    (collision with tail, did not clear food)
    
    

    While I'm fine changing the description myself, I'm not going anywhere near tests. Someone with more experience can implement this.

  • Custom User Avatar

    I mentioned this below. There are no tests to see whether food is eaten twice. Logically, food should vanish off the field when consumed. My solution doesn't do this, but it currently doesn't matter. One would have to add a test where a solution that doesn't clear the food after consuming it causes the head to collide with the tail (because it grew when it shouldn't), making it fail.

  • Default User Avatar

    Description doesn't say if food can be used multiple times or only once.

    Both versions pass the tests (at least in python).

  • Loading more items...