-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathscoring.py
More file actions
86 lines (80 loc) · 2.61 KB
/
scoring.py
File metadata and controls
86 lines (80 loc) · 2.61 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
input_src = "input_example"
submission_src = "submission_example"
def writeCovered():
for rowNumber in range(H):
for colNumber in range(W):
if(Routers[rowNumber][colNumber]==1):
manageRouter(rowNumber,colNumber)
def manageRouter(rowNumber,colNumber):
minCol = colNumber - R
maxCol = colNumber + R +1
minRow = rowNumber -R
maxRow = rowNumber + R +1
for row in range(minRow,maxRow):
for col in range(minCol,maxCol):
if(checkArea(rowNumber,colNumber,row,col)):
CoveredCells[row][col] = 1
def checkArea(rowNumber,colNumber,row,col):
if(
(row<0)|(row>=H)|(col<0)|(col>=W)
):
return False
else:
if((Grid[row][col]=='#')|(Grid[row][col]=='-')):
return False
else:
value = True
minRow = min([rowNumber,row])
maxRow = max([rowNumber, row])
minCol = min([colNumber, col])
maxCol = max([colNumber, col])
for nrow in range(minRow,maxRow + 1):
for ncol in range(minCol,maxCol + 1):
if (Grid[nrow][ncol] == '#'):
value = False
return value
with open(input_src) as f:
content = f.readlines()
firstLine = content[0].split(" ")
H = int(firstLine[0])
W = int(firstLine[1])
R = int(firstLine[2])
firstLine = content[1].split(" ")
Pb = int(firstLine[0])
Pr = int(firstLine[1])
B = int(firstLine[2])
firstLine = content[2].split(" ")
Br = int(firstLine[0])
Bc = int(firstLine[0])
line=3
Grid = [[0 for x in range(W)] for y in range(H)]
for rowNumber in range(H):
row = list(content[line])
for colNumber in range(W):
Grid[rowNumber][colNumber] = row[colNumber]
line=line+1
with open(submission_src) as f:
content = f.readlines()
line = 0
N = int(content[line])
line = line + 1
BackboneCells = [[0 for x in range(W)] for y in range(H)]
for i in range(N):
cellRC = content[line].split(" ")
BackboneCells[int(cellRC[0])][int(cellRC[1])] = 1
line = line + 1
M = int(content[line])
line = line + 1
Routers = [[0 for x in range(W)] for y in range(H)]
for i in range(M):
cellR = content[line].split(" ")
Routers[int(cellR[0])][int(cellR[1])] = 1
line = line + 1
CoveredCells = [[0 for x in range(W)] for y in range(H)]
writeCovered()
t= sum(sum(CoveredCells, []))
score = 1000*t+(B-(N*Pb+M*Pr))
print("Score: ",score)