this time with no legal info

This commit is contained in:
2025-12-08 01:11:02 +00:00
commit 2f38ac9096
29 changed files with 72807 additions and 0 deletions

33
7/ex1.py Normal file
View File

@@ -0,0 +1,33 @@
import numpy as np
count = 0
grid = []
with open('input.txt') as file:
num_cols = len(file.readline().strip('\n'))
file.seek(0)
num_lines = 0
for line in file:
num_lines += 1
for i in range(num_cols):
grid.append(line[i])
grid = np.array(grid).reshape((num_lines, num_cols))
beams = set()
for row in grid:
for i in range(len(row)):
if row[i] == 'S':
beams.add(i)
elif row[i] == '^':
if i in beams:
count += 1
beams.remove(i)
if i - 1 not in beams:
beams.add(i - 1)
if i + 1 not in beams:
beams.add(i + 1)
print(count)