diff options
author | Anton Luka Šijanec <anton@sijanec.eu> | 2023-12-10 17:35:43 +0100 |
---|---|---|
committer | Anton Luka Šijanec <anton@sijanec.eu> | 2023-12-10 17:35:43 +0100 |
commit | 9c5442674a2c36af1b787e40eb50c9a99ea2667b (patch) | |
tree | 5d159a211e2b7ce187d991ddb14b870029685760 | |
parent | aoc10 (diff) | |
download | r-9c5442674a2c36af1b787e40eb50c9a99ea2667b.tar r-9c5442674a2c36af1b787e40eb50c9a99ea2667b.tar.gz r-9c5442674a2c36af1b787e40eb50c9a99ea2667b.tar.bz2 r-9c5442674a2c36af1b787e40eb50c9a99ea2667b.tar.lz r-9c5442674a2c36af1b787e40eb50c9a99ea2667b.tar.xz r-9c5442674a2c36af1b787e40eb50c9a99ea2667b.tar.zst r-9c5442674a2c36af1b787e40eb50c9a99ea2667b.zip |
Diffstat (limited to '')
-rw-r--r-- | prog/aoc/23/10/} | 92 |
1 files changed, 0 insertions, 92 deletions
diff --git a/prog/aoc/23/10/} b/prog/aoc/23/10/} deleted file mode 100644 index 96ac727..0000000 --- a/prog/aoc/23/10/} +++ /dev/null @@ -1,92 +0,0 @@ -#!/usr/bin/python3 -from mmap import mmap -from sys import argv -file = open(argv[1], "r+b") -b = mmap(file.fileno(), 0) -linelen = b.find(b'\n')+1 -numlines = len(b)/linelen -S = b.find(b'S') -def korak(idx, camefrom): - if chr(b[idx]) in ['S', "-", "J", "7"]: - if idx%linelen != 0: - if chr(b[idx-1]) in ["-", "L", "F", "S"]: - if camefrom != idx-1: - return idx-1 - if chr(b[idx]) in ['S', "-", "F", "L"]: - if idx%linelen != -2%linelen: - if chr(b[idx+1]) in ["-", "J", "7", "S"]: - if camefrom != idx+1: - return idx+1 - if chr(b[idx]) in ['S', "|", "F", "7"]: - if idx//linelen != linelen-1: - if chr(b[idx+linelen]) in ["|", "L", "J", "S"]: - if camefrom != idx+linelen: - return idx+linelen - if chr(b[idx]) in ['S', "|", "J", "L"]: - if idx//linelen != 0: - if chr(b[idx-linelen]) in ["|", "F", "7", "S"]: - if camefrom != idx-linelen: - return idx-linelen -pos = S -prev = -1 -numsteps = 0 -tiles = [] -while numsteps == 0 or pos != S: - pos, prev = korak(pos, prev), pos - # print("korak iz ", prev//linelen, ", ", prev%linelen, "na ", pos//linelen, ", ", pos%linelen) - tiles.append(pos) - numsteps += 1 -print(numsteps//2) -print(tiles) -larger = max(tiles[0], tiles[-2]) -smaller = min(tiles[0], tiles[-2]) -print(smaller, larger, S) -schar = None -if larger-smaller == 2: - schar = "-" -if larger-smaller == 2*linelen: - schar = "|" -if smaller+linelen+1 == larger: - if smaller == S-1: - schar = "7" - else: - schar = "L" -if smaller+linelen-1 == larger: - if smaller == S+1: - schar = "F" - else: - schar = "J" -x3 = {} -def postavi(pos): - line = pos//linelen - column = pos%linelen - x3[(line*3+1, column*3+1)] = True - znak = chr(b[pos]) - if pos == S: - znak = schar - match znak: - case "-": - x3[(line*3+1, column*3+1+1)] = True - x3[(line*3+1, column*3+1-1)] = True - case "|": - x3[(line*3+1+1, column*3+1)] = True - x3[(line*3+1-1, column*3+1)] = True - case "L": - x3[(line*3+1-1, column*3+1)] = True - x3[(line*3+1, column*3+1+1)] = True - case "J": - x3[(line*3+1-1, column*3+1)] = True - x3[(line*3+1, column*3+1-1)] = True - case "7": - x3[(line*3+1+1, column*3+1)] = True - x3[(line*3+1, column*3+1-1)] = True - case "F": - x3[(line*3+1+1, column*3+1)] = True - x3[(line*3+1, column*3+1+1)] = True -for tile in tiles: - postavi(tile) -fillstack = [(0, linelen-1)] -def fill(): - -while len(fillstack) > 0: - fill(a.pop()) |