Ad
  • Custom User Avatar

    I'd suggest using Array#length or Array#size instead of Array#count here as they don't check whether a block was given.

    Awesome solution overall, the array-adding one-liner is pure gold for readability here.

  • Custom User Avatar

    The description size 10 example ends on the element [5][5]. Shouldn't it be able to move to the element [5][4] before ending? I'm guessing the intended starting point is the element [0][0], so at the element [5][5] the snake is moving to the left. If this is the case, moving to the element [5][4] wouldn't mean it touched itself.

    The description should specify what is considered an empty element:

    1. the element that has at least one '.' field in between other '0' elements in EVERY direction except the element the snake/spiral is coming from
    2. the element that has at least one '.' field in between other '0' elements in the direction the snake/spiral is moving towards

    It should also specify the starting point.