Ad
  • Custom User Avatar

    for the first else if where (!puzzle[x][y]) you return rec((x+1)%9,y+(x==9?1:0)) but x will never equal 9 because of %9 so this can be replaced with return rec((x+1)%9,y+1) since you have the catch at the top for where y == 9. Very nice solution though.

  • Custom User Avatar

    When thinking of an array, I think of x as the column and y as the row.

    For example, the array [[1,2,3],[4,5,6],[7,8,9]] would be displayed as
    [1,2,3]
    [4,5,6]
    [7,8,9]

    not as
    [1,4,7]
    [2,5,8]
    [3,6,9]

    So I would think of a Miner sitting on 2 in my array as having coordinates of {x:1, y:0} not {x:0, y:1}. The Miner and exit coordinates are set with x and y coordinates using my later example, it gets confusing....

  • Custom User Avatar

    One issue I see with this is if the word is one character like "I" which would return "IIay".

    Putting in if(el.length > 1) el = el.slice(1) + el.slice(0, 1); return el + "ay" in the map function would fix that.