Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: python
before_install:
- git clone https://github.com/$TRAVIS_REPO_SLUG.git original
- rm -rf .test; mv original/.test .test
-
install:
- .test/install
script:
Expand Down
65 changes: 65 additions & 0 deletions solution.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import numpy as np
import sys
from math import sqrt, fabs


def Newton(n ,m):
def silnia(x):
a = 1
for i in range(2, x + 1):
a *= i
return a

return silnia(n ) /silnia(m ) /silnia( n -m)


def Pascal(n):
li = np.array([[0 for i in range(j+1)] for j in range(n)])
for i in range(n):
li[i][0] = 1
li[i][i] = 1
if i>1:
for j in range(i-1):
li[i][j+1]=li[i-1][j] + li[i-1][j+1]
return li

def LotOfHash(n):
li = Pascal(n)
for i in li:
for j in i:
if j%2 == 1:
sys.stdout.write("#")
else:
sys.stdout.write(" ")
print""

def PowerModulo(a,b,n):
w1 = a**b
w2 = w1%n
return w2

def Intersect((x1,y1,r1),(x2,y2,r2)):
w =[]
e = x2 - x1
f = y2 - y1
p = sqrt(e ** 2 + f ** 2) #odleglosc miedzy srodkami okregow
k = (p ** 2 + r1 ** 2 - r2 ** 2) / (2*p)
if p>r1+r1 or p<fabs(r1-r2): #okregi rozlaczne
pass
elif p==r1+r2 or p==fabs(r1-r2): #okregi styczne
x = x1 + e*k / p + (f / p)*sqrt(r1 ** 2 - k ** 2)
y = y1 + f*k / p - (e / p)*sqrt(r1 ** 2 - k ** 2)
p = (x,y)
w.append(p)
else: #okregi przecinaja sie
x01 = x1 + e * k / p + (f / p) * sqrt(r1 ** 2 - k ** 2)
y01 = y1 + f * k / p - (e / p) * sqrt(r1 ** 2 - k ** 2)
p1 = (x01, y01)
w.append(p1)

x02 = x1 + e * k / p - (f / p) * sqrt(r1 ** 2 - k ** 2)
y02 = y1 + f * k / p + (e / p) * sqrt(r1 ** 2 - k ** 2)
p2 = (x02, y02)
w.append(p2)

return w
60 changes: 60 additions & 0 deletions solution/solution.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import numpy as np
import sys
from math import sqrt, fabs


def Newton(n ,m):
def silnia(x):
a = 1
for i in range(2, x + 1):
a *= i
return a

return silnia(n ) /silnia(m ) /silnia( n -m)


def Pascal(n):
li = np.array([[0 for i in range(j+1)] for j in range(n)])
for i in range(n):
li[i][0] = 1
li[i][i] = 1
if i>1:
for j in range(i-1):
li[i][j+1]=li[i-1][j] + li[i-1][j+1]
return li

def LotOfHash(n):
li = Pascal(n)
for i in li:
for j in i:
if j%2 == 1:
sys.stdout.write("#")
else:
sys.stdout.write(" ")
print""

def PowerModulo(a,b,n):
w1 = a**b
w2 = w1%n
print w2

def Intersect((x1,y1,r1),(x2,y2,r2)):
w =[]
e = x2 - x1
f = y2 - y1
p = sqrt(e ** 2 + f ** 2) #odleglosc miedzy srodkami okregow
k = (p ** 2 + r1 ** 2 - r2 ** 2) / (2*p)
if p>r1+r1 or p<fabs(r1-r2): #okregi rozlaczne
pass
elif p==r1+r2 or p==fabs(r1-r2): #okregi styczne
x = x1 + e*k / p + (f / p)*sqrt(r1 ** 2 - k ** 2)
y = y1 + f*k / p - (e / p)*sqrt(r1 ** 2 - k ** 2)
w = [x,y]
else: #okregi przecinaja sie
x01 = x1 + e * k / p + (f / p) * sqrt(r1 ** 2 - k ** 2)
y01 = y1 + f * k / p - (e / p) * sqrt(r1 ** 2 - k ** 2)

x02 = x1 + e * k / p - (f / p) * sqrt(r1 ** 2 - k ** 2)
y02 = y1 + f * k / p + (e / p) * sqrt(r1 ** 2 - k ** 2)
w = [(x01,y01),(x02,y02)]
print w
17 changes: 17 additions & 0 deletions solution/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from solution import *


print Newton(200,2)
print""
print Pascal(6)
print""
LotOfHash(6)
print""
PowerModulo(2,200,100)
print""
Intersect( (0,0,5), (6,0,5) )
# [ (3, 4), (3,-4) ]
Intersect( (0,0,5), (10,0,5) )
# [ (5, 0) ]
Intersect( (0,0,5), (15,0,5) )
# [ ]
17 changes: 17 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from solution import *


print Newton(200,2)
print""
print Pascal(6)
print""
LotOfHash(6)
print""
print PowerModulo(2,200,100)
print""
print Intersect( (0,0,5), (6,0,5) )
# [ (3, 4), (3,-4) ]
print Intersect( (0,0,5), (10,0,5) )
# [ (5, 0) ]
print Intersect( (0,0,5), (15,0,5) )
# [ ]