Ad
  • Custom User Avatar

    Not with rec((x + 1) % 9, y + 1), but with rec((x + 1) % 9, y). But even in this case, to move to the next row, the recursion would need to walk through the current row once again. And only in the second walk, when it is on the last cell, it checks that the cell is filled, it moves to the next row. If (y + 1) is used, then the recursion would change the row every time it meets empty cell.

  • Custom User Avatar

    Already raised as issue

  • Custom User Avatar

    This also will have some issues no? For example if I put "!!!" at the end it will return wrong string. Even with only "!" at the end or any single character for that matter, You forgot to put the character back, 'if(el.length > 1)' will simply skip the single character :)

  • Custom User Avatar

    This is a good point. The instructions state that the input map is not a traditional computer science map, which is traditionally configured as you state; each subarray is a row (not a column), and the values of the subarray refer to the columns (not rows). I can handle this flip because it's explained in the instructions, but what is very confusing is that the instructions do not state how x and y are related to columns and rows. All that is stated is that x: 0, y: 0 refers to top-left. It should be stated more clearly in the instructions whether the x refers to the columns (i.e. the sub arrays in the map) or the rows, (the value of each sub array), especially since they redefined how a 2D map is configured with 2D arrays.

  • 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.