-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path#main.py#
executable file
·55 lines (30 loc) · 1017 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import sys
def is_estetic(slice, L):
ingredients = [ingredient for ingredient in [row for row in slice]]
return ingredients.count(0) == L and ingredients.count(1) == L
def size(slice):
return len(slice) * len(slice[0])
def find_better_slice(slize, pizza):
def backtrack(slice, i, pizza):
if not is_estetic(slice):
return
if size(slice) == H:
return slice
better_slice = find_better_slice(slice, i, )
def slice(pizza):
return backtrack([], 0, pizza)
def main():
input_file_name = (len(sys.argv) > 1 and sys.argv[1]) or "datasets/example.in"
print(input_file_name)
input = open(input_file_name, "r")
str_args = input.readline().split(" ")
args = [int(str_arg) for str_arg in str_args]
[TOTAL_ROWS, TOTAL_COLS, L, H] = args
pizza = []
for row in input:
pizza += [[1 if col == "T" else 0 for col in row]]
slices = slice(pizza)
print TOTAL_ROWS, TOTAL_COLS, L, H
print pizza
print slices
main()