Skip to content

Instantly share code, notes, and snippets.

@bogensberger bogensberger/nipple.py Secret
Last active Apr 28, 2020

Embed
What would you like to do?
nipple.py
import math
nippel = (22, 75)
def number_to_coordinates(number):
x = (number -1) % 10
y = min(math.floor(number / 10), 9)
return (x,y)
def distance_to_nippel(coordinate, nippel):
a = abs(nippel[0] - coordinate[0])
b = abs(nippel[1] - coordinate[1])
return math.sqrt(math.pow(a, 2) + math.pow(b, 2))
nippelA = number_to_coordinates(nippel[0])
nippelB = number_to_coordinates(nippel[1])
def nippel_coefficient(coordinateA, coordinateB):
return min(
distance_to_nippel(number_to_coordinates(coordinateA), nippelA) + distance_to_nippel(number_to_coordinates(coordinateB), nippelB),
distance_to_nippel(number_to_coordinates(coordinateA), nippelB) + distance_to_nippel(number_to_coordinates(coordinateB), nippelA)
)
tips = {
"ben": (44, 47),
"janusz": (83, 87),
"sigs": (65, 88),
"jan": (44, 57),
"marco": (93, 96),
"yvonne": (24, 27),
"philipp": (35, 37),
"jan_r": (55, 58),
"sebastian": (48, 55),
"sebastian_h": (35, 48),
"marco": (48, 55),
}
result = {}
for member in tips:
tip = tips[member]
result[member] = nippel_coefficient(tip[0], tip[1])
print(sorted(result.items(), key=lambda item: item[1]));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.