From 02e4f16a7d28f3bf0a9e4a76ed7b1e8b27b04691 Mon Sep 17 00:00:00 2001 From: taraspiotr Date: Fri, 20 May 2016 12:20:51 +0200 Subject: [PATCH 01/10] nic takiego --- .idea/vcs.xml | 6 ++++++ solution.py | 0 test.py | 0 3 files changed, 6 insertions(+) create mode 100644 .idea/vcs.xml create mode 100644 solution.py create mode 100644 test.py diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/solution.py b/solution.py new file mode 100644 index 0000000..e69de29 diff --git a/test.py b/test.py new file mode 100644 index 0000000..e69de29 From e65419ef3ae7c020ec8ce9982ed44a4957d939de Mon Sep 17 00:00:00 2001 From: taraspiotr Date: Fri, 20 May 2016 12:36:40 +0200 Subject: [PATCH 02/10] nic takiego --- solution.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/solution.py b/solution.py index e69de29..53668de 100644 --- a/solution.py +++ b/solution.py @@ -0,0 +1,14 @@ +def Newton(n, m): + + if(m > n/2): + m = n-m + licznik = 1 + for i in range(n-m+1, n+1): + licznik *= i + mianownik = 1 + for i in range(1, m+1): + mianownik *= i + return licznik/mianownik + + + From 85817f524727d0ffc51b9cf95ed4db098ec11303 Mon Sep 17 00:00:00 2001 From: taraspiotr Date: Fri, 20 May 2016 12:41:06 +0200 Subject: [PATCH 03/10] nic takiego --- solution.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/solution.py b/solution.py index 53668de..4966a57 100644 --- a/solution.py +++ b/solution.py @@ -12,3 +12,15 @@ def Newton(n, m): +def Pascal(n): + pass + + +def LotOfHash(n): + pass + +def PowerModulo(a, b, n): + pass + +def Intersect(a,b): + pass \ No newline at end of file From f6abf14d55d2363f9d058e0556be409dee9106af Mon Sep 17 00:00:00 2001 From: taraspiotr Date: Fri, 20 May 2016 13:56:22 +0200 Subject: [PATCH 04/10] nic takiego --- solution.py | 54 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 4 deletions(-) diff --git a/solution.py b/solution.py index 4966a57..e3ca97b 100644 --- a/solution.py +++ b/solution.py @@ -13,14 +13,60 @@ def Newton(n, m): def Pascal(n): - pass + i = 1 + triangle = [[1]] + while i < n: + temp = [1] + for j in range(1, i): + temp.append(triangle[i-1][j-1] + triangle[i-1][j]) + temp.append(1) + triangle.append(temp) + i += 1 + return triangle def LotOfHash(n): - pass + triangle = Pascal(n) + for row in triangle: + temp = "" + for elem in row: + if elem % 2 == 1: + temp += "#" + else: + temp += " " + print temp + def PowerModulo(a, b, n): - pass + c = 1 + e = 0 + while e < b: + e += 1 + c = (a * c) % n + return c + + def Intersect(a,b): - pass \ No newline at end of file + x1, y1, r1 = a + x2, y2, r2 = b + + def norm(a, b): + return pow(pow(a,2) + pow(b,2), 0.5) + + l = norm(x1 - x2, y1- y2) + w = [(x2 - x1) / l, (y2 - y1) / l] + if l > r1 + r2: + return [] + + elif l == r1 + r2: + inter = [x1 + w[0]*r1, y1 + w[1]*r1] + return inter + else: + x = (pow(l,2) + pow(r1, 2) - pow(r2, 2))/(2*l) + h = pow(pow(r1,2) - pow(x,2), 0.5) + inter1 = [x1 + x*w[0] + h*w[1], y1 + x*w[1] - h*w[0]] + inter2 = [x1 + x*w[0] - h*w[1], y1 + x*w[1] + h*w[0]] + return [inter1, inter2] + + From a75d8024c0aecec02d182c6461ab8cc2d3cc4622 Mon Sep 17 00:00:00 2001 From: taraspiotr Date: Fri, 20 May 2016 13:58:57 +0200 Subject: [PATCH 05/10] nic takiego --- solution.py | 1 + 1 file changed, 1 insertion(+) diff --git a/solution.py b/solution.py index e3ca97b..acc8ece 100644 --- a/solution.py +++ b/solution.py @@ -62,6 +62,7 @@ def norm(a, b): elif l == r1 + r2: inter = [x1 + w[0]*r1, y1 + w[1]*r1] return inter + else: x = (pow(l,2) + pow(r1, 2) - pow(r2, 2))/(2*l) h = pow(pow(r1,2) - pow(x,2), 0.5) From 94ac1abd2ce93aca4ab7015e30ecb70ccf323f96 Mon Sep 17 00:00:00 2001 From: taraspiotr Date: Fri, 20 May 2016 14:01:48 +0200 Subject: [PATCH 06/10] nic takiego --- solution.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/solution.py b/solution.py index acc8ece..140db28 100644 --- a/solution.py +++ b/solution.py @@ -60,14 +60,12 @@ def norm(a, b): return [] elif l == r1 + r2: - inter = [x1 + w[0]*r1, y1 + w[1]*r1] - return inter - + inter = (x1 + w[0]*r1, y1 + w[1]*r1) + return [inter] + else: x = (pow(l,2) + pow(r1, 2) - pow(r2, 2))/(2*l) h = pow(pow(r1,2) - pow(x,2), 0.5) - inter1 = [x1 + x*w[0] + h*w[1], y1 + x*w[1] - h*w[0]] - inter2 = [x1 + x*w[0] - h*w[1], y1 + x*w[1] + h*w[0]] + inter1 = (x1 + x*w[0] + h*w[1], y1 + x*w[1] - h*w[0]) + inter2 = (x1 + x*w[0] - h*w[1], y1 + x*w[1] + h*w[0]) return [inter1, inter2] - - From 6f5107d96be6a84b2ec5f7c23f928f6276899222 Mon Sep 17 00:00:00 2001 From: taraspiotr Date: Fri, 20 May 2016 14:02:19 +0200 Subject: [PATCH 07/10] nic takiego --- solution.py | 1 + 1 file changed, 1 insertion(+) diff --git a/solution.py b/solution.py index 140db28..154e527 100644 --- a/solution.py +++ b/solution.py @@ -69,3 +69,4 @@ def norm(a, b): inter1 = (x1 + x*w[0] + h*w[1], y1 + x*w[1] - h*w[0]) inter2 = (x1 + x*w[0] - h*w[1], y1 + x*w[1] + h*w[0]) return [inter1, inter2] + From 35b9ec3d2da834ea015ecd04412fcb480c10c951 Mon Sep 17 00:00:00 2001 From: taraspiotr Date: Fri, 20 May 2016 14:02:32 +0200 Subject: [PATCH 08/10] nic takiego --- solution.py | 1 + 1 file changed, 1 insertion(+) diff --git a/solution.py b/solution.py index 154e527..e224069 100644 --- a/solution.py +++ b/solution.py @@ -70,3 +70,4 @@ def norm(a, b): inter2 = (x1 + x*w[0] - h*w[1], y1 + x*w[1] + h*w[0]) return [inter1, inter2] + From 9b68313cb1841296ce01112276f510e72d1418d5 Mon Sep 17 00:00:00 2001 From: taraspiotr Date: Sat, 21 May 2016 19:04:42 +0200 Subject: [PATCH 09/10] nic takiego --- solution.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/solution.py b/solution.py index e224069..f1a5d6a 100644 --- a/solution.py +++ b/solution.py @@ -38,12 +38,19 @@ def LotOfHash(n): def PowerModulo(a, b, n): - c = 1 - e = 0 - while e < b: - e += 1 - c = (a * c) % n - return c + + binary = bin(b)[2:] + wynik = 1 + i = 0 + m = a % n + while i < len(binary): + if binary[-1-i] == "1": + wynik = wynik*m % n + i += 1 + m = pow(m, 2) % n + return wynik + + From 056c36db4414746833318d23dd02d0b35db2d1bb Mon Sep 17 00:00:00 2001 From: taraspiotr Date: Sat, 21 May 2016 19:04:56 +0200 Subject: [PATCH 10/10] nic takiego --- solution.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/solution.py b/solution.py index f1a5d6a..43ab21f 100644 --- a/solution.py +++ b/solution.py @@ -52,8 +52,6 @@ def PowerModulo(a, b, n): - - def Intersect(a,b): x1, y1, r1 = a x2, y2, r2 = b