from math import acos, hypot, pi
def angle(l):
if len(l) < 3:
return []
res = []
(ax, ay), (bx, by), *l = l
abx, aby = bx - ax, by - ay
len_ab = hypot(abx, aby)
for cx, cy in l:
bcx, bcy = cx - bx, cy - by
len_bc = hypot(bcx, bcy)
res.append(round(acos((abx * bcx + aby * bcy) /
(len_ab * len_bc)) * 180 / pi))
ax, ay, bx, by, abx, aby, len_ab = \
bx, by, cx, cy, bcx, bcy, len_bc
return res
# квадрат
aa = angle([(0, 0), (1, 0), (1, 1), (0, 1), (0, 0), (1, 0)])
print(sum(aa), aa)
# кривой "квадрат"
aa = angle([(0, 0), (11, 0), (12, 9), (1, 11), (2, -1), (9, 0)])
print(sum(aa), aa)
res.add( # type(res) == set
int( # int("123") == 123, type("123") == str, type(123) = int
''.join( # см ниже
digs # digs == ('1','2',3')
)
)
)
for s in '', '+', '!=':
print(s.join(['a', 'bc', 'def']))
from itertools import permutations
combinations = [''.join(c) for c in permutations('1234')] # был лишний квалификатор itertools.
print(combinations) # херовая идея так использовать это имя одновременно с импортом из itertools
public static final float PI = 3.14;
. Кошмар, но вот так ) function reduceFrac(numerator, denomerator) {
let a = numerator, b = denomerator;
while (a) {
let c = b % a;
b = a;
a = c;
}
return [numerator / b, denomerator / b]
}