-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
37 lines (25 loc) · 809 Bytes
/
main.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
import sys
from dp import *
def read_file(filename):
path = './Data/' + filename + '.in'
with open(path, 'r') as f:
spec = f.readline().split()
target, number = int(spec[0]), int(spec[1])
candidates = list(map(int, f.readline().split()))
return target, number, candidates
def wirte(results, filename):
path = './Output/' + filename + '.txt'
with open(filename, 'w') as f:
f.write('{}\n'.format(len(results)))
for res in results:
f.write(str(res) + ' ')
def main():
if len(sys.argv) < 2:
print("No input file !!")
exit()
filename = sys.argv[1]
target, number, candidates = read_file(filename)
res = solve_pizza(candidates, target)
wirte(res, filename)
if __name__ == '__main__':
main()