mirror of
https://github.com/Xevion/contest.git
synced 2025-12-08 12:06:43 -06:00
move all contest solutions into proper practice folder in prep for real problem solution
This commit is contained in:
28
icpc/ecna-regional-contest-2018/practice/A/main.py
Normal file
28
icpc/ecna-regional-contest-2018/practice/A/main.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import sys, os, math
|
||||
|
||||
# Pythagorean Distance Formula
|
||||
def pyth(x1, y1, x2, y2):
|
||||
return math.sqrt(((x1 - x2) ** 2) + ((y1 - y2) ** 2))
|
||||
|
||||
def dist(spot1, spot2):
|
||||
return pyth(spot1[0], spot1[1], spot2[0], spot2[1])
|
||||
|
||||
def main():
|
||||
def parse(dat):
|
||||
return list(map(int, dat.split()))
|
||||
|
||||
|
||||
path = os.path.join(sys.path[0], 'input')
|
||||
data = open(path, 'r').read().split('\n')
|
||||
listeners = []
|
||||
|
||||
|
||||
for dataset in data:
|
||||
listeners.append(parse(dataset))
|
||||
spy = listeners.pop(0)
|
||||
|
||||
distances = sorted(list(map(lambda x : dist(spy, x), listeners)))
|
||||
print(int(distances[:2][-1]))
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user