From f6f0e5356eb01d5e19e1f1a2b9256eed1e964ddb Mon Sep 17 00:00:00 2001 From: Anastasios Grammenos Date: Mon, 26 Oct 2020 14:20:24 +0200 Subject: Fix for the trivial case --- 3.2.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to '3.2.py') diff --git a/3.2.py b/3.2.py index 8006d21..f7dfc04 100644 --- a/3.2.py +++ b/3.2.py @@ -258,7 +258,6 @@ def getMatrixInverse(m): cofactors[r][c] = cofactors[r][c]/d return cofactors - def find_lcm(a): lcm = a[0] for i in a[1:]: @@ -276,6 +275,8 @@ def simplify(b): return c def solution(m): + if len(m) == 1: + return [1,1] m = sort(m) n = normalize(m,use_fractions=True) (q, r) = decompose(n) @@ -300,3 +301,13 @@ print(solution([[0, 1, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]])) # [0, 3, 2, 9, 14] + +print(solution([[0, 1, 31, 10, 1, 1], + [11, 0, 1, 23, 0, 0], + [51, 1, 0, 1, 0, 0], + [21, 31, 51, 0, 0, 1], + [0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0]])) + +# THE TRIVIAL FucKING CASE +print(solution([[0]])) -- cgit v1.2.3