-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathccc23j4.py
57 lines (51 loc) · 1.26 KB
/
ccc23j4.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
56
57
import ccc
params = ccc.load_std_input_file("ccc23j4.log")
row_cnt = int(params[0][0])
first_row = params[1][0]
second_row = params[2][0]
tape_len = 0
# first row
for i in range(0, row_cnt):
if first_row[i] == "0": # dry
continue
else: # wet
# left
if i == 0:
tape_len += 1
else:
if first_row[i - 1] == "0":
tape_len += 1
# right
if i == row_cnt - 1:
tape_len += 1
else:
if first_row[i + 1] == "0":
tape_len += 1
if i + 1 % 2 == 0: # top
tape_len += 1 # top
else: # bottom
if second_row[i] == "0":
tape_len += 1
# second row
for i in range(0, row_cnt):
if second_row[i] == "0":
continue
else: # wet
# left
if i == 0:
tape_len += 1
else:
if second_row[i - 1] == "0":
tape_len += 1
# right
if i == row_cnt - 1:
tape_len += 1
else:
if second_row[i + 1] == "0":
tape_len += 1
if (i + 1) % 2 == 0: # bottom
tape_len += 1
else:
if first_row[i] == "0":
tape_len += 1
print(tape_len)