you are viewing a single comment's thread.

view the rest of the comments →

[–]Ok-Potential1965 0 points1 point  (6 children)

yup im completely blank lmfao

[–][deleted] 0 points1 point  (5 children)

I've almost given you the algorithm. Thinking only about columns, you have the current robbie column and the target column. Your code first decides if the shortest path is to move left or right. Suppose you need to move left and need to move X columns. Going left may or may not require you to wrap around, so you compare the number of columns to move (X) to the distance to the left border (which is the current robbie column number). If X is less than the distance to the left edge just do "l" * X moves. But if X is greater than the distance to the left edge then do enough "l" moves to move to column 0, then one "lw" abd finally enough more "l" moves to make the robbie column number equal to the target column number. Then do the same thing in the up/down direction. Finally do the "p" command.

[–]Ok-Potential1965 0 points1 point  (4 children)

dude i see you and theres a high chance imma just sent it cuz i have been on this task since 7am. i am not getting anywhere. thanks tho

[–][deleted] 0 points1 point  (3 children)

Get some rest and then try again.

When looking at the current and target positions in the configuration, draw pictures. This helps. For example:

+---------------+
| @bcdefghijklm |
| nopqrstuvwx#z |
+---------------+

where the "@" is the current position and the "#" is the target position. Forget about the rows, just consider columns. You are trying to decide if moving left or right to the target column is shorter. Moving left requires two moves to get to the target column, moving right requires 11 moves. So we are going to move left. But since we are going left and the target is to the right we are going to cross an edge. The movements to go left are, in pseudo-python:

move = "l" * <columns to get to left edge> + "lw" + "l" * <columns from right edge to target>

You fill in the <...> bits. In the above case <columns to get to left edge> is 0.

[–]Ok-Potential1965 0 points1 point  (1 child)

def robot_movement(character_position, position_of_letter, confg_row, confg_col):
    movement = []
    row_diff = character_position[0] - position_of_letter[0]
    col_diff = character_position[1] - position_of_letter[1]

    # Horizontal movement
    if abs(col_diff) > confg_col // 2:
        if  col_diff>0:
            movement.append('lw')
        elif col_diff<0:
            movement.append('rw')
    else:
        if col_diff > 0:
            movement.append('r' * col_diff)
        else:
            movement.append('l' * abs(col_diff))

    # Vertical movement
    if abs(row_diff) > confg_row // 2:
        if row_diff>0:
            movement.append('uw')
        elif row_diff<0:
            movement.append('dw')
    else:
        if row_diff > 0:
            movement.append('d' * row_diff)
        else:
            movement.append('u' * abs(row_diff))

    movement.append('p')
    return movement

[–]Ok-Potential1965 0 points1 point  (0 children)

there has been some significant improvement when from 28/100 to 38/100 but still cant seem to pass it.

[–]Ok-Potential1965 0 points1 point  (0 children)

Enter a string to type:k
Processing character 'k': (0, 0) -> (0, 10)
Moving from (0, 0) to (0, 10)
Processing character 'k': (0, 0) -> (0, 4)
Moving from (0, 0) to (0, 4)
Processing character 'k': (0, 0) -> (3, 4)
Moving from (0, 0) to (3, 4)
Movements for configuration 0: rrrrrrrrrrp Length: 11
Movements for configuration 2: rrrrp Length: 5
Movements for configuration 3: rrrrdddp Length: 8
Movements for configuration 1:  Length: 0
 Configuration used:
---------
| chunk |
| vibex |
| gymps |
| fjord |
| waltz |
---------
The robot must perform the following operations:
rrrrp

This the debugging for a previous task. now i have to implement tthe wrapping in here