summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnastasios Grammenos <anastasios.grammenos@noris.gr>2020-10-26 14:20:24 +0200
committerAnastasios Grammenos <anastasios.grammenos@noris.gr>2020-10-26 14:20:24 +0200
commitf6f0e5356eb01d5e19e1f1a2b9256eed1e964ddb (patch)
treed04d471737033c3c7bbe21fe6f56b3c36073b081
parentf28878613810f0b1b1deafe6c733522f02d0ceb6 (diff)
downloadfoobar-withgoogle-f6f0e5356eb01d5e19e1f1a2b9256eed1e964ddb.tar.gz
foobar-withgoogle-f6f0e5356eb01d5e19e1f1a2b9256eed1e964ddb.tar.bz2
foobar-withgoogle-f6f0e5356eb01d5e19e1f1a2b9256eed1e964ddb.zip
Fix for the trivial case
-rw-r--r--3.2.py13
1 files changed, 12 insertions, 1 deletions
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]]))