Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if __name__ == "__main__":
- with open("input.txt", "r") as f:
- data = [
- (
- int(
- not all(
- c == "#"
- for c in [row for row in schematic.strip().split("\n") if row][
- 0
- ]
- )
- ),
- [
- len(
- [
- 1
- for row in (
- range(
- 1,
- len(
- [
- row
- for row in schematic.strip().split("\n")
- if row
- ]
- ),
- )
- if all(
- c == "#"
- for c in [
- row
- for row in schematic.strip().split("\n")
- if row
- ][0]
- )
- else range(
- len(
- [
- row
- for row in schematic.strip().split("\n")
- if row
- ]
- )
- - 2,
- -1,
- -1,
- )
- )
- if [row for row in schematic.strip().split("\n") if row][
- row
- ][col]
- == "#"
- ]
- )
- for col in range(
- len([row for row in schematic.strip().split("\n") if row][0])
- )
- ],
- )
- for schematic in f.read().strip().split("\n\n")
- ]
- print(
- len(
- set(
- tuple(sorted([lock[0], key[0]]))
- for lock in [(i, h) for i, (t, h) in enumerate(data) if t == 0]
- for key in [(i, h) for i, (t, h) in enumerate(data) if t == 1]
- if all(i + j <= 5 for i, j in zip(lock[1], key[1]))
- )
- )
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement