From 3bc6367a902c6e1c460deaba7c388cba058c4099 Mon Sep 17 00:00:00 2001 From: secminhr Date: Mon, 15 Oct 2018 08:04:36 +0800 Subject: [PATCH] bug on moving fr, fl, br, bl --- cli/algo.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cli/algo.py b/cli/algo.py index c8eef39..d233a5a 100644 --- a/cli/algo.py +++ b/cli/algo.py @@ -143,7 +143,8 @@ def _getLowerCross(row, col, arr): def shiftRightUp(row, col, num, seats): # the list is follows the predicate: n.row > (n+1).row corner_list, highest_pos = _getUpperCross(row, col, seats) - corner_list = _arrShiftLeft(row - highest_pos[0] ,corner_list, num) + target = seats[row-1][col-1] + corner_list = _arrShiftLeft(corner_list.index(target) ,corner_list, num) #fill in current_row = highest_pos[0] current_col = highest_pos[1] @@ -157,7 +158,8 @@ def shiftRightUp(row, col, num, seats): def shiftRightDown(row, col, num, seats): # the list is follows the predicate: n.row > (n+1).row corner_list, highest_pos = _getLowerCross(row, col, seats) - corner_list = _arrShiftRight(row - highest_pos[0] ,corner_list, num) + target = seats[row-1][col-1] + corner_list = _arrShiftRight(corner_list.index(target) ,corner_list, num) #fill in current_row = highest_pos[0] current_col = highest_pos[1] @@ -170,7 +172,8 @@ def shiftRightDown(row, col, num, seats): def shiftLeftUp(row, col, num, seats): corner_list, highest_pos = _getLowerCross(row, col, seats) - corner_list = _arrShiftLeft(highest_pos[0] - row ,corner_list, num) + target = seats[row-1][col-1] + corner_list = _arrShiftLeft(corner_list.index(target) ,corner_list, num) #fill in current_row = highest_pos[0] current_col = highest_pos[1] @@ -183,7 +186,8 @@ def shiftLeftUp(row, col, num, seats): def shiftLeftDown(row, col, num, seats): corner_list, highest_pos = _getUpperCross(row, col, seats) - corner_list = _arrShiftRight(row - highest_pos[0] ,corner_list, num) + target = seats[row-1][col-1] + corner_list = _arrShiftRight(corner_list.index(target) ,corner_list, num) #fill in current_row = highest_pos[0] current_col = highest_pos[1]