def navigate_waypoint( instructions ):
    """
    From the starting point of the ship (0,0) and the ship's waypoint at (10,1), 
    the ship has to be navigated based on the command and delta mentioned 
    in each instruction. The waypoint is a reference point relative to the
    ship, and it moves with the ship.

    The positions are modelled as complex numbers. The direction conventions
    can be understood by referring to move_along dictionary in the code below.  
    
    Navigation:
      - If the command is 'F', the ship moves by delta times the waypoint. 
      - If the command is ['N','E','W','S'], the waypoint moves by delta according 
        to the corresponding direction described in move_along.
      - If the command is 'L', the waypoint is rotated counterclockwise.
        i.e., For N to be rotated to W, waypoint is multiplied by complex(0,1) raised
        to the power of (angle/90) -> 90 = once, 180 = twice, 270 = thrice.
      - If the command is 'R', the waypoint is rotated clockwise.
        i.e., For N to be rotated to E, waypoint is multiplied by complex(0,-1) raised
        to the power of (angle/90) -> 90 = once, 180 = twice, 270 = thrice.

    Task:
    This function returns the manhattan distance of the position from starting
    point which was (0,0) -> distance = abs(real) + abs(imag)
    """
    position    = complex(0,0)
    move_along  = {'N': complex( 0, 1), 'S': complex( 0,-1),
                   'E': complex( 1, 0), 'W': complex(-1, 0) }
    waypoint    = complex(10,1)
    for command, delta in instructions:
        if command == 'F':
            position += delta * waypoint
        elif command in ['N','E','W','S']:
            waypoint += delta * move_along[ command ]
        elif command == 'L':
            waypoint *= complex(0, 1) ** (delta//90)
        else:
            assert command == 'R'
            waypoint *= complex(0,-1) ** (delta//90)            
    return int(abs(position.real)+abs(position.imag))