-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path10.py
41 lines (30 loc) · 892 Bytes
/
10.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import math
import time
day = "10"
inFile = open('inputs/{}.in'.format(day), "r")
start_time = time.time()
board = []
for line in inFile:
line = line.strip("\n")
row = []
for item in line:
if(item == '.'):
row.append(0)
else:
row.append(1)
board.append(row)
def calcSight(r,c):
if(board[r][c] == 0):
return 0
angles = []
for i in range(len(board)):
for j in range(len(board)):
if(board[i][j] == 1 and (i,j != r,c)):
angles.append((math.atan2(r-i, c-j)))
return len(set(angles))
result = [[0 for y in range(len(board[0]))] for x in range(len(board))]
for i in range(0,len(board)):
for j in range(0,len(board[i])):
result[i][j] = calcSight(i,j)
print(max(map(max, result)))
print('Execution time: {} ms'.format(round((time.time() - start_time)*1000, 1)))