From d774775cb2d77f6995a98296e57c1169ee84037c Mon Sep 17 00:00:00 2001 From: Ilya Grigorev Date: Sat, 9 Nov 2024 20:28:35 +0300 Subject: [PATCH] fix merge conflict --- main.py | 15 ++++++++------- test.py | 24 ++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 7 deletions(-) create mode 100644 test.py diff --git a/main.py b/main.py index 45a4fbd..93b4289 100644 --- a/main.py +++ b/main.py @@ -86,8 +86,8 @@ def Vogel( solution_matrix[y][x] = val C_numerated = np.zeros((C_init_height, C_init_length), dtype=np.int64) - C_numerated = np.insert(C_numerated, 0, [str(i+1) for i in range( C_init_length)], axis=0) - C_numerated = np.insert(C_numerated, 0, [str(i) for i in range( C_init_height+1)], axis=1) + C_numerated = np.insert(C_numerated, 0, [i+1 for i in range( C_init_length)], axis=0) + C_numerated = np.insert(C_numerated, 0, [i for i in range( C_init_height+1)], axis=1) @@ -131,8 +131,8 @@ def Vogel( target_number = min(target_array) x = np.where(target_array == target_number)[0][0] - x_num = C_numerated[0][x+1] - y_num = C_numerated[y+1][0] + x_num = C_numerated[y+1][0] + y_num = C_numerated[0][x+1] if (D[x] >= S[y]): @@ -160,9 +160,10 @@ def Vogel( target_array = C.T[np.where(ColD == maxD)[0]][0] target_number = min(target_array) y = np.where(target_array == target_number)[0][0] + print(ColD[x], target_array[y]) - x_num = C_numerated[0][x+1] - y_num = C_numerated[y+1][0] + x_num = C_numerated[y+1][0] + y_num = C_numerated[0][x+1] if (D[x] >= S[y]): row_index_to_eleminate = y @@ -285,7 +286,7 @@ def print_problem_statement( if len(str(matrix[y][x])) == 1: row += " " if (y == len(matrix)-1): - table += f"\n{"_ " * ((len(matrix[0])-1) * 2)}" + table += "\n" + "_ " * ((len(matrix[0])-1) * 2) table += f"\n{row}" print(table) print(print_problem_statement(S,C,D)) diff --git a/test.py b/test.py new file mode 100644 index 0000000..d325748 --- /dev/null +++ b/test.py @@ -0,0 +1,24 @@ +from main import Vogel +import numpy as np + +C = np.array([ + [7, 8, 1, 2], + [4, 5, 9, 8], + [9, 2, 3, 6], +], dtype=np.int64) + +S = np.array([ + 160, 140, 170 +], dtype=np.int64) + +D = np.array([ + 120, 50, 190, 110 +], dtype=np.int64) + +VogelExpected = np.array([ + [0, 0, 50, 110], + [120, 20, 0, 0], + [0, 30, 140, 0], +], dtype=np.int64) + +print(Vogel(S, C, D).solution)