2025-12-07 08:11:12 +00:00

26 lines
567 B
Python

def solve(input):
splits = 0
pos = []
for row in open(input):
row = row.strip()
next = []
for i in pos:
if row[i] == '.':
next.append(i)
elif row[i] == '^':
if i-1 >= 0:
next.append(i-1)
if i+1 < len(row):
next.append(i+1)
splits += 1
start = row.find('S')
if start >= 0:
next.append(start)
pos = sorted(set(next))
print(splits)
solve("sample")
solve("input")