Ad
  • Custom User Avatar

    what kind of sorcery is this?

  • Custom User Avatar

    Good one. Funny. I didn't actually laughed though.

  • Default User Avatar

    Based on the tags, I'd assume the author intended a regex solution but I would always endorse built-in functions when they're more succinct and readable. :)

  • Custom User Avatar

    You are right... I guess I was temporaly blinded. Thanks Unnamed.

  • Default User Avatar

    So even in such short a description you managed to miss a whole sentence...

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    Well, the kata says it takes place in the desert, and while I guess you can have insurmountable dunes, it does not include such enitites in the description (which would be an entirely different problem). The drawing above is furthermore misleading - on the left hand side you go 2 steps east, then 1 north (even if it is drawn as 2 east, 2 north) while on the right hand side it is 3 north, 1 east (again, drawn as 3 north, 2 east). Assuming that each step of the instructions are all of unit 1 (otherwise, SOUTH NORTH would not necessarily end up the same place), the drawings really reprents the two paths

    EAST EAST NORTH   
    NORTH NORTH NORTH EAST
    

    which are clearly not the same thing.

    The kata really only need a few words to make the task more clear, such as to say what is meant by not reasonable i.e., two consequitive steps in opposing directions.

    I think the confussion comes from the fact that naturally takes the set of operations {NORTH,SOUTH,EAST,WEST} as commutative and associative. That is for any three operators a, b, and c in the set

    a * b = b * a
    (a * b) * c = a * (b * c)
    

    but the test breaks that intuition. What the test seems to say is that operators in the same vertical or horizontal direction are commutative

    NORTH SOUTH = SOUTH NORTH = id
    WEST EAST = EAST WEST = id
    

    but not between horizontal and vertical directions

    NORTH EAST /= EAST NORTH
    WEST SOUTH /= SOUTH WEST 
    

    nor are the operations associative between vertical and horizontal

    (NORTH SOUTH) EAST /= NORTH (SOUTH EAST) 
    

    (this may seem odd, but on the left-hand side the (NORTH SOUTH) is the identity, but on the right hand side (SOUTH EAST) does not reduce). Thus, the kata is really dealing with two algebraic groups

    {NORTH,SOUTH,id}
    {EAST,WEST,id}

    for which the convolution operations are commutative and associative within each group separately but not between the groups. This, I think, is not how people read the kata - they think of the single algebraic group

    {NORTH,SOUTH,EAST,WEST,id}

    with a single convolution operator.

  • Custom User Avatar

    either going North - East or East - North will end up at the same place

    Are you sure?

      Going east        Going north
    and then north     and then east
     _________          _________
     |       |          | → →   |
     |   ____|          | ↑ ____|
     |   | ↑ |          | ↑ |   |
     | → → ↑ |          | ↑     |
     |_______|          |_______|
    

    If you get different result, then you're reducing the array wrong somehow.

  • Custom User Avatar

    Expected: '['EAST', 'NORTH']', instead got: '['NORTH', 'EAST']'

    Isn't the same? I mean, my result is correctly reducting the direction, either going North - East or East - North will end up at the same place.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Finally got it & passed the kata. Thanks for your tips and patience Chrono! Ure the man.

  • Custom User Avatar

    Yes, it was, but you mutated it.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Ok, thanks guys.

  • Custom User Avatar

    The error is right what the error message says: you're trying to reverse what you're expecting to be an array while, in fact, it's an undefined value. Also, passing the sample tests doesn't mean that you will definitely pass the main tests.

    Not a kata issue.

  • Loading more items...