Ad
  • Custom User Avatar

    im amazed by these one line solutions!
    nicely done.

  • Custom User Avatar

    Oh, I got it now. You were right, I was couting rows and columns (row 0, row 1..., column 0, column 1). Thanks so much!

  • Default User Avatar
    grid = [
        0123x
      0'aB..',
      1'##@#',
      2'$Ab#'
      y
    ]
    

    0, 0 is top left, that's an a
    with x-axis being right-left, that means @ is two steps right, so x-axis is 2, and it's one down, so y-axis is 1: (x, y) (2, 1)
    I.. don't see how you're getting (1, 2) for @

    (1,2) (x,y), and the first step in order to go to the key is going up to (0,2)

    if (1,2) is x,y, then you changed the x coordinate but said you're going up, which is vertical(up/down) movement, but you said x is horizontal(left/right)

    .. no clue where we're viewing this differently x)

  • Custom User Avatar

    I explained bad myself, I think. Not talking of writting the grid but the position you should step. I mean, in the first example the first position (the starting "@") should be (1,2) (x,y), and the first step in order to go to the key is going up to (0,2), right? So when you say the array that should be returned with the pair x-y steps, you said "[(2, 1), (2, 0)...", there is where I am lost. Sorry for my clumsy english, I am explaining myself as hell...

  • Default User Avatar

    Do you mean that you're writing grid[x][y]? That would be you swapping them, since grid contains rows, not columns.

    avoiding the variable names x and y may help. try row and col. and you should always consider re-structuring any input data you receive to suit you.

  • Custom User Avatar

    Hello, sorry for the dumb-newbie question but I don't understand the first example. I mean, I suppose isn't wrong 'cause have been tested and achieved so some of them will pointed to it of ot were the case, but, "x" and "y" seems to be swapped to me. If "x" is for horizontal and "y" is for vertical: won't be "@" (1, 2) and first step to (0, 2), then (0, 1) and so on? Thanks.

  • Default User Avatar
  • Custom User Avatar

    Hi, I think you have the sample tests and the actual tests swapped around

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

    Copy that. Thank you!

  • Custom User Avatar

    not usually best practice, in real life strive for readibility while being able to make your code shorter

  • Default User Avatar

    I keep forgetting I don't need to make new variables for everything and it can all usually fit inside a return statement. Unsure at my level if that is the best practice, but the fewer lines of code is what I'm currently striving for as I learn.

  • Custom User Avatar

    please do acknowledge that the compile time is much higher than the for-loop approach...
    my for-loop approach:
    Execution time: 0.0000375 seconds

    regex approach:
    Execution time: 0.0007297 seconds

  • Custom User Avatar
  • Loading more items...