index
int64
0
0
repo_id
stringclasses
16 values
file_path
stringlengths
34
106
content
stringlengths
24
327k
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/21_me.py
from collections import deque # lines = open("example.in").read().strip().split("\n") lines = open("21.in").read().strip().split("\n") M1 = {} M2 = {} for line in lines: m, n = line.split(": ") if n.isnumeric(): M1[m] = int(n) else: M2[m] = n X = deque() O = deque() while M2: for k, v...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/21.py
#!/usr/bin/python3 import sys import math from copy import deepcopy from collections import defaultdict, deque infile = sys.argv[1] if len(sys.argv) > 1 else "21.in" infile = sys.argv[1] if len(sys.argv) > 1 else "example.in" data = open(infile).read().strip() lines = [x for x in data.split("\n")] E = {} def f(name...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/15.py
#!/usr/bin/python3 import sys import math from copy import deepcopy from collections import defaultdict, deque infile = sys.argv[1] if len(sys.argv) > 1 else "15.in" data = open(infile).read().strip() lines = [x for x in data.split("\n")] S = set() B = set() sum_d = 0 for line in lines: words = line.split() s...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/8.py
#!/usr/bin/python3 import sys from collections import defaultdict infile = sys.argv[1] if len(sys.argv)>1 else '8.in' data = open(infile).read().strip() lines = [x for x in data.split('\n')] G = [] for line in lines: row = line G.append(row) DIR = [(-1,0),(0,1),(1,0),(0,-1)] R = len(G) C = len(G[0]) p1 = 0 f...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/6.in
wzsspbssbhshchmmrmprmrfrsfrrjhjphjjtppbfflqfqppdhdbhdhbbjgghgzgsgfsfhfhvvwcwhwwnppsbsggqnnvvtffpssjfjnnltntdtdddptprppjmmqssrlrplllfrrzggbmmlmnmtnnzddfdgfdfsstbstbbzcbbcjcvvfwwwzlzssglsgllnbnmbnmbbgmmppmwwsrrzqqvgqgnqnmmswwrnnbsnnbdbwwqnwqnwwzzqwzqzjqqwbqbccjcwwjlwjwppqfqjffwddrzrjzrjzzzhchjjlqqrggzvvnlvnvjvhvnvjvbbvdv...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/11.py
#!/usr/bin/python3 import sys import math from copy import deepcopy from collections import defaultdict infile = sys.argv[1] if len(sys.argv) > 1 else "11.in" data = open(infile).read().strip() lines = [x for x in data.split("\n")] M = [] OP = [] DIV = [] TRUE = [] FALSE = [] for monkey in data.split("\n\n"): id_...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/23_me.py
from collections import deque from copy import deepcopy lines = open("23.in").read().strip().split("\n") # lines = open("example.in").read().strip().split("\n") E = set() for j, line in enumerate(lines): for i, l in enumerate(line): if l == '#': E.add((i,j)) c = 0 # move counter P = [ ((-...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/9.py
#!/usr/bin/python3 import sys from collections import defaultdict infile = sys.argv[1] if len(sys.argv) > 1 else "9.in" data = open(infile).read().strip() lines = [x for x in data.split("\n")] def adjust(H, T): dr = H[0] - T[0] dc = H[1] - T[1] if abs(dr) <= 1 and abs(dc) <= 1: # ok pass ...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/7.in
$ cd / $ ls dir dpbwg dir dvwfscw dir hccpl dir jsgbg dir lhjmzsl 63532 mwvbpw.mmg 239480 npj dir pngs dir qhs 303649 shvgmwn.vhv 236905 sjrrgd.phh dir sntcp dir sqs $ cd dpbwg $ ls dir dgh 100731 dpbwg dir rpwnv $ cd dgh $ ls 197049 lhjmzsl.hzj $ cd .. $ cd rpwnv $ ls 10702 qsgv.fmf $ cd .. $ cd .. $ cd dvwfscw $ ls d...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/4_me.py
X = [l.strip() for l in open("4.in")] pairs_overlapped = 0 pairs_contained = 0 for i in X: a, b = i.split(",") a1, a2 = a.split("-") b1, b2 = b.split("-") a_list = list(range(int(a1), int(a2) + 1)) b_list = list(range(int(b1), int(b2) + 1)) if any(elem in a_list for elem in b_list) or any(e...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/3.in
CjhshBJCSrTTsLwqwqwb GtmnFHlDfcpHbLZjtTTRLWwb fDfNHHjVFNvvrvVBJJdS PPWvWQjPhrPQwlMWJJdMDGbJTdCJ rsqsStgNNggBNBZHSrJGdJdCFRRZCFbGbTdJ qgBqqHzzggBpzSnBNqNSSSgcfhrVlVmwPljQVLVwVvQmmzVl bBBGBfmGvBTnGtGJBtGpcJbZrrddjqrZhDldwdcqrjrjDr HWPSQMsPHFsMWPVVMVSHCwDCDwwZZvwjwQZZwjdd vVHPgHHFRLfpfJTLLtJL LWLZhDBHhWWHjBwHwBjCTrBnnrQTQ...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/18_me.py
from collections import deque lines = open("18.in").read().strip().split("\n") P = set() for line in lines: x, y, z = [int(coor) for coor in line.split(",")] P.add((x, y, z)) OUT = set() IN = set() def reach_outside(x, y, z, part): if (x, y, z) in OUT: return True if (x, y, z) in IN: ...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/14_me2.py
with open("14.in") as f: lines = [l.strip() for l in f] R = set() for l in lines: ll = [_ for _ in l.split("->")] for i in range(len(ll) - 1): x1, y1 = ll[i].strip().split(",") x2, y2 = ll[i + 1].strip().split(",") for i in range(min(int(x1), int(x2)), max(int(x1), int(x2)) + 1): ...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/20.py
#!/usr/bin/python3 import sys import math from copy import deepcopy from collections import defaultdict, deque infile = sys.argv[1] if len(sys.argv) > 1 else "20.in" data = open(infile).read().strip() lines = [x for x in data.split("\n")] def solve(part): X = [int(x) for x in lines] if part == 2: X =...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/14.py
#!/usr/bin/python3 import sys import math from copy import deepcopy from collections import defaultdict, deque infile = sys.argv[1] if len(sys.argv) > 1 else "14.in" data = open(infile).read().strip() lines = [x for x in data.split("\n")] R = set() for line in lines: prev = None for point in line.split("->"):...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/6_me.py
with open("6.in") as f: X = [l for l in f.read()] start_of_packet = 0 for i in range(len(X) - 13): if start_of_packet == 0 and len(set(X[i : i + 4])) == 4: start_of_packet = i + 4 continue if len(set(X[i : i + 14])) == 14: break print(start_of_packet) print(i + 14)
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/25_me.py
from collections import deque from copy import deepcopy lines = open("25.in").read().strip().split("\n") # lines = open("example.in").read().strip().split('\n') SNAFU =[] for line in lines: SNAFU.append(line.strip()) to_dec = { '2': 2, '1': 1, '0': 0, '-': -1, '=': -2 } D = [] while SNAFU: n = SNAFU.pop() ...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/8.in
200120010031113332213034140102430141241124321111512323442304040044220141342121012210022220211111200 111021120230012003124233312003010303204555454332453445353125225214221214442214301113012111020220220 010000112330232223210123331341111021455213441355415452453433542411022110033014112420103200010200112 21022013102320303302...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/1_me.py
with open("1.in") as f: X = [l.strip() for l in f.read().split("\n\n")] print(X) Q = [] for i in X: q = 0 for j in i.split("\n"): q += int(j) Q.append(q) print(max(Q)) print([Q.index(i) + 1 for i in Q if i == max(Q)])
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/11.in
Monkey 0: Starting items: 80 Operation: new = old * 5 Test: divisible by 2 If true: throw to monkey 4 If false: throw to monkey 3 Monkey 1: Starting items: 75, 83, 74 Operation: new = old + 7 Test: divisible by 7 If true: throw to monkey 5 If false: throw to monkey 6 Monkey 2: Starting i...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/25.in
2010-0122=0=2-10 2- 2=0=0 1200==-1201 1==-==1-=002- 1=-=--- 1=2 1211-=00=21102-0= 1-=2-120110- 1--2-0=101-=2122= 11=- 2=1--=20=1 1= 1010===-1222 221=12010=20=-12 1==122- 212 100-==2 1122-- 2--2==0= 2=-==2-20 2=-12=22100 1-1-=--22 2-1-201 221=10= 12-=-002-1022=- 1-12-00012 1=---0122----00 220102=020- 20=-22-2=21-1 1-1-2...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/22_me.py
from collections import deque example = True # example = False if example: lines = open("example.in").read().split("\n\n") else: lines = open("22.in").read().split("\n\n") M = [line for line in lines[:-1][0].split("\n")] instr = lines[-1] R = len(M) C = max(len(x) for x in M) CUBE = C // (4 if example else 3)...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/2.py
X = [l.strip() for l in open("2.in")] p1 = 0 p2 = 0 for x in X: op, me = x.split() p1 += {"X": 1, "Y": 2, "Z": 3}[me] p1 += { ("A", "X"): 3, ("A", "Y"): 6, ("A", "Z"): 0, ("B", "X"): 0, ("B", "Y"): 3, ("B", "Z"): 6, ("C", "X"): 6, ("C", "Y"): 0...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/20_me.py
from collections import deque # lines = open("example.in").read().strip().split("\n") lines = open("20.in").read().strip().split("\n") def solve(p): if p == 2: X = [int(line) * 811589153 for line in lines] else: X = [int(line) for line in lines] X = deque(list(enumerate(X))) for mixin...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/3_me.py
X = [l.strip() for l in open("3.in")] lower = [chr(ord("a") + i) for i in range(26)] upper = [chr(ord("A") + i) for i in range(26)] alphabet = lower + upper total = 0 for x in X: first_half, seond_half = x[: len(x) // 2], x[len(x) // 2 :] for ch1 in first_half: if ch1 in seond_half: prin...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/21.in
lzvm: ptgl * wvjc jlbw: 5 vgzr: 2 scpf: 3 lgtp: 2 srsp: vdmg * fqbh hcmw: 7 cnpc: 9 scvq: wzpm - cnwd nvml: 3 rlvv: 7 ffrw: lscf + jcht lprr: 2 srpn: 2 hspb: gdhj + fbbc bhsc: 4 hdtw: qfmd * wntp sjhs: mfjc - nwcz wtgh: 17 rjvw: hzjt * lnlw cwpc: 2 wtqw: 3 tnhb: 2 dvrh: 3 znnv: wthv / qczc qpln: wspn * jpnc phbj: wnzd ...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/15.in
Sensor at x=3988693, y=3986119: closest beacon is at x=3979063, y=3856315 Sensor at x=1129181, y=241785: closest beacon is at x=1973630, y=-98830 Sensor at x=2761889, y=2453622: closest beacon is at x=2803715, y=2643139 Sensor at x=3805407, y=3099635: closest beacon is at x=3744251, y=2600851 Sensor at x=3835655, y=399...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/3.py
def score(c): if "a" <= c <= "z": return ord(c) - ord("a") + 1 else: return ord(c) - ord("A") + 1 + 26 # p1 = 0 # for line in open("3.in"): # x = line.strip() # assert len(x) % 2 == 0 # y, z = x[: len(x) // 2], x[len(x) // 2 :] # for c in y: # if c in z: # p...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/day16p2.py
from collections import deque valves = {} tunnels = {} for line in open("16.in"): line = line.strip() valve = line.split()[1] flow = int(line.split(";")[0].split("=")[1]) targets = line.split("to ")[1].split(" ", 1)[1].split(", ") valves[valve] = flow tunnels[valve] = targets dists = {} nonem...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/24_me.py
from collections import deque from copy import deepcopy lines = open("24.in").read().strip().split("\n") # lines = open("example.in").read().strip().split("\n") start = [i for i, l in enumerate(lines[0]) if l == '.'] start = (start[0], 0) exit = [i for i, l in enumerate(lines[-1]) if l == '.'] exit = (exit[0], len(l...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/7_me.py
with open("7.in") as f: lines = [l.strip() for l in f.readlines()] d = {} for l in lines: if l.startswith("$ cd"): dir = l[5:] if dir == "/": cwd = "/" elif dir == "..": cwd = cwd[: cwd[:-1].rfind("/")] + "/" else: cwd = cwd + dir + "/" ...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/20.in
2061 7683 5447 -7582 -7439 8426 -5141 1388 662 -9447 -6189 -8863 -4476 -4258 6576 -3939 -9961 967 9709 -4962 -2475 6536 7823 7472 967 5894 -7309 3368 5796 -9621 1804 1671 -6756 6407 -9104 -9258 -6393 -6826 -2330 6028 -8109 2253 -6752 -2302 1791 -6890 3321 -8507 5342 89 -7509 812 2304 -308 218 9296 -3052 -3601 -2800 -60...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/19_me.py
from collections import deque def solve(Co, Cc, Co1, Co2, Cg1, Cg2, T): best = 0 SEEN = set() Q = deque([(0, 0, 0, 0, 1, 0, 0, 0, T)]) Core = max(Co, Cc, Co1, Cg1) while Q: state = Q.popleft() o, c, ob, g, r0, r1, r2, r3, t = state if t == 0: best = max(best, g...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/14.in
494,23 -> 494,17 -> 494,23 -> 496,23 -> 496,20 -> 496,23 -> 498,23 -> 498,16 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,19 -> 502,23 -> 504,23 -> 504,18 -> 504,23 496,36 -> 496,34 -> 496,36 -> 498,36 -> 498,30 -> 498,36 -> 500,36 -> 500,31 -> 500,36 -> 502,36 -> 502,27 -> 502,36 -> 504,36 -> 504,29 -> 504...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/9.in
R 5 U 8 L 8 D 3 R 17 D 10 L 25 U 20
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/5_me.py
with open("5.in") as f: X = [l for l in f.read().split("\n\n")] stacks = [] stacks2 = [] for i in X[0].split("\n")[-1].split(None): stacks.append([]) stacks2.append([]) for j in X[0].split("\n")[:-1]: for m in range(len(stacks)): if j[m * 4 + 1] != " ": stacks[m].append(j[m * 4 + ...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/10.in
addx 2 addx 4 noop noop addx 17 noop addx -11 addx -1 addx 4 noop noop addx 6 noop noop addx -14 addx 19 noop addx 4 noop noop addx 1 addx 4 addx -20 addx 21 addx -38 noop addx 7 noop addx 3 noop addx 22 noop addx -17 addx 2 addx 3 noop addx 2 addx 3 noop addx 2 addx -8 addx 9 addx 2 noop noop addx 7 addx 2 addx -27 ad...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/24.in
#.######################################################################################################################## #>v<^v>v^.^>v<v.^<.^v>^v^<^v^^v.><^v^v<><>><^>^>>>vv..>.^<<>><^<v>^vv<>^v<v>v>.<><<<><>>v..v<^^vv^^vv.^v^^>^^^.^v^vv<<^v.# #><^vvv^^vv>v>^<^v^^<^<v<<v><.^<^v><>>^>^^^.>^v>>..<<>>^>><^^v<^<<^^>^><<>...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/readme.md
https://github.com/jonathanpaulson/AdventOfCode/tree/master/2022
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/day16p1.py
from collections import deque valves = {} tunnels = {} for line in open("16.in"): line = line.strip() valve = line.split()[1] flow = int(line.split(";")[0].split("=")[1]) targets = line.split("to ")[1].split(" ", 1)[1].split(", ") valves[valve] = flow tunnels[valve] = targets dists = {} nonem...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/23.in
.##.####.#.#..###....##.....#.#.#.###.#####..#..#...#..#.##.##.#..#####.#. #.#..####..#...#.####..#.#..##.###..#.#...#.#..##..##.#...#..#####.#.####. .#.#.####..##.##.#..###..#..#...#.##..#.#.###....####..#..#.#...#.#..##... #..###..#..#.#.##.#...#.#.#.#.#....##..##.##.##...#..##.....##...#...##... #...##..#.####.#.#.#...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/19.py
#!/usr/bin/python3 import sys import math from copy import deepcopy from collections import defaultdict, deque # infile = sys.argv[1] if len(sys.argv) > 1 else "example.in" infile = sys.argv[1] if len(sys.argv) > 1 else "19.in" data = open(infile).read().strip() lines = [x for x in data.split("\n")] def solve(Co, Cc...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/9_me.py
with open("9.in") as f: lines = [l.strip() for l in f] H = (5, 0) T = [(5, 0) for _ in range(9)] p1 = set() p2 = set() DR = {"R": 0, "L": 0, "U": -1, "D": 1} DC = {"R": 1, "L": -1, "U": 0, "D": 0} def displayAllTail(H, T): rows, cols = (6, 6) for row in range(rows): for col in range(cols): ...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/17.in
>><<<<>><>>>><><<>>>><<<>>>><<<<>>><>>>><<<<>>>><<><><<<><<><<<<><<<<>>>><<>>><<<>><<>>><<><<<>>>><>>><<><>><<>>><<<<><>><<>>><<<<><<<<><>><<<<>>><<<<>>>><<<>><><<<<>>><>><<<>><><<<>>><<<<>>><>>>><<<><<>>>><><<<<>>>><<<>>>><>>>><>>>><><<><<>>>><<<>>><<<>>>><><<<><<<<>><>>><<<<><<<><>><><><<><<><<<<>>>><<<<>>><>>><<<><<...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/17_me.py
from collections import deque D = open("17.in").read().strip() LD = len(D) R = [ [0b0011110], [0b0001000, 0b0011100, 0b0001000], [0b0000100, 0b0000100, 0b0011100], [0b0010000, 0b0010000, 0b0010000, 0b0010000], [0b0011000, 0b0011000], ] C1 = [0b1111111] C2 = [] def draw_chamber(): for i in ran...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/15_me.py
sensors = [] beacons = [] dist = [] for line in open("15.in"): data = line.split() sx, sy, bx, by = ( int(data[2][2:-1]), int(data[3][2:-1]), int(data[8][2:-1]), int(data[9][2:]), ) sensors.append((sx, sy)) beacons.append((bx, by)) dist.append(abs(sx - bx) + abs(s...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/17_me2.py
D = open("17.in").read().strip() def get_piece(t, y): match t % 5: case 0: return set([(2, y), (3, y), (4, y), (5, y)]) case 1: return set([(3, y), (2, y + 1), (3, y + 1), (4, y + 1), (3, y + 2)]) case 2: return set([(2, y), (3, y), (4, y), (4, y + 1), (...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/21_me2.py
from collections import deque # lines = open("example.in").read().strip().split("\n") lines = open("21.in").read().strip().split("\n") M = {} for line in lines: m, n = line.split(": ") M[m] = n def f(k, p, h_value=0): if p == 2 and k == "humn": return h_value try: return int(M[k]) ...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/13.in
[[[[8,6,7],9,7,10],[[2,2,4],0,[4,9,10],[4,8,1,1],9],5],[8,8,[5,7],1,3],[],[6,[1,[0,1],[6,10,9]]],[]] [[[6,7,0,[0,3,9],8],[9,[],[10,0,5,6,8],[1,8,1],[]],[],[[0,6],5,[5,8,9],1]],[0,[10],[],8,[[5],6,10,10,2]],[[1,6,[6,0,4],[9,8],[5,5]]],[3,1,5,6]] [[4,[[]]],[],[[1]],[]] [[5,[[7,3,2,4]],3,[]],[[[4,5,3],6,10,[5,3,3],5],[[]...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/5.py
#!/usr/bin/python3 import sys from copy import deepcopy infile = sys.argv[1] if len(sys.argv) > 1 else "5.in" data = open(infile).read() lines = [x for x in data.split("\n")] S = [] cmds = [] for line in lines: if line == "": break sz = (len(line) + 1) // 4 while len(S) < sz: S.append([]) ...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/15_me2.py
sensors = [] beacons = set() for line in open("15.in"): data = line.split() sx, sy, bx, by = ( int(data[2][2:-1]), int(data[3][2:-1]), int(data[8][2:-1]), int(data[9][2:]), ) d = abs(sx - bx) + abs(sy - by) sensors.append((sx, sy, d)) beacons.add((bx, by)) def v...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/11_me.py
with open("11.in") as f: lines = [l.strip() for l in f.read().strip().split("\n\n")] I = [] M = [[], []] OP = [] DIV = [] TRUE = [] FALSE = [] for l in lines: _, items, op, test, true, false = l.split("\n") M[0].append([int(i.strip()) for i in (items.split(":")[-1].split(","))]) M[1].append([int(i.str...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/12.in
abcccccaaaccccaacaaccaaaaaaaaaaaaaaaaaaaaccccccccccccccccccccccccccccccccccaaaaaa abcccccaaaacccaaaaaccaaaaaaaaaaaaaaaaaaaaacccccccccccccccccccccccccccccccccccaaaa abcccccaaaaccaaaaaccccaaaccaaaaaacccacaaaaccccccccccccccccaaaccccccccccccccccaaaa abcccccaaacccaaaaaaccccccccaaaaaacccccaaccccccccccccccccccaaaccccccccccccc...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/1.py
X = [l.strip() for l in open("1.in")] Q = [] for elf in ("\n".join(X)).split("\n\n"): q = 0 for x in elf.split("\n"): q += int(x) Q.append(q) Q = sorted(Q) print(Q[-1]) print(Q[-1] + Q[-2] + Q[-3])
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/13_me.py
from copy import deepcopy with open("13.in") as f: lines = [l.strip() for l in f.read().split("\n\n")] D = [] for line in lines: D.append([eval(_) for _ in line.split("\n")]) S = [] for d1, d2 in D: S.append(d1) S.append(d2) def check_in_order(l, r): c = min(len(l), len(r)) for cc in range(c...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/22.in
..................#..#.....#....................#............#.......#..##.......................... .#...#.....#.........................................#...##...#...#....#...................#........ ...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/18.py
#!/usr/bin/python3 import sys from collections import defaultdict, deque infile = sys.argv[1] if len(sys.argv) > 1 else "18.in" data = open(infile).read().strip() lines = [x for x in data.split("\n")] P = set() for line in lines: x, y, z = line.split(",") x, y, z = int(x), int(y), int(z) P.add((x, y, z)) ...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/16.in
Valve HM has flow rate=0; tunnels lead to valves LS, YS Valve IY has flow rate=15; tunnels lead to valves YI, MU, KN, QS, QM Valve VI has flow rate=22; tunnels lead to valves LE, SE, RB, JR Valve SE has flow rate=0; tunnels lead to valves VI, AZ Valve QU has flow rate=0; tunnels lead to valves YC, QK Valve RB has flow ...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/14_me.py
with open("14.in") as f: lines = [l.strip() for l in f] R = [] for l in lines: ll = [_ for _ in l.split("->")] for i in range(len(ll) - 1): x1, y1 = ll[i].strip().split(",") x2, y2 = ll[i + 1].strip().split(",") for i in range(int(min(x1, x2)), int(max(x1, x2)) + 1): for...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/4.in
71-87,70-88 8-92,6-97 7-68,8-69 47-47,47-48 74-94,51-93 48-63,48-49 26-57,57-58 62-63,11-76 16-66,15-47 27-65,27-62 19-81,19-81 19-19,18-18 4-5,5-15 75-84,39-75 96-96,20-83 1-59,28-60 13-14,14-88 15-96,96-99 4-64,1-4 22-95,42-95 52-53,52-78 58-75,63-67 25-75,63-76 10-19,9-37 46-81,65-65 4-61,5-62 66-66,67-67 45-82,83-9...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/13.py
#!/usr/bin/python3 import sys import math from copy import deepcopy from collections import defaultdict, deque infile = sys.argv[1] if len(sys.argv)>1 else '13.in' data = open(infile).read().strip() lines = [x for x in data.split('\n')] def compare(p1,p2): if isinstance(p1, int) and isinstance(p2,int): if...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/16_me.py
from collections import deque rates = {} tunnels = {} bitmask = {} for b, line in enumerate(open("16.in")): scan = line.split() v, r, t = scan[1], int(scan[4][5:-1]), [_.strip(",") for _ in scan[9:]] rates[v] = int(r) tunnels[v] = t bitmask[v] = 1 << b dist = {} for valve, rate in [r for r in rate...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/19.in
Blueprint 1: Each ore robot costs 3 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 18 clay. Each geode robot costs 3 ore and 8 obsidian. Blueprint 2: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 2 ore and 18 clay. Each geode robot costs 4 ore and 20 obsidian....
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/17.py
#!/usr/bin/python3 import sys import math from copy import deepcopy from collections import defaultdict, deque infile = sys.argv[1] if len(sys.argv) > 1 else "17.in" data = open(infile).read().strip() lines = [x for x in data.split("\n")] def get_piece(t, y): # set of (x,y) pairs if t == 0: return set([...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/8_me.py
with open("8.in") as f: lines = [l.strip() for l in f] R = len(lines) C = len(lines[0]) p1 = 0 for r in range(R): for c in range(C): t = lines[r][c] visible = False for dr, dc in [(1, 0), (0, 1), (-1, 0), (0, -1)]: rr = r cc = c while True: ...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/12_me.py
from collections import defaultdict, deque with open("12.in") as f: lines = [l.strip() for l in f] G = [] for line in lines: G.append(line) R = len(G) C = len(G[0]) E = [[0 for _ in range(C)] for _ in range(R)] Q = deque() for i in range(R): for j in range(C): if G[i][j] == "E": E[i]...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/1.in
10130 9819 4257 8400 10994 3758 8326 9002 15602 1193 6805 10797 9435 6559 11512 12051 2687 2850 3752 6656 5869 5033 7164 1708 3689 2218 6642 1913 1494 1403 4269 6089 3985 4673 4814 6628 6076 3594 3143 5412 7647 22393 2865 2241 1877 2289 1928 1519 4750 5669 3725 3706 4640 4078 11277 6678 15419 18306 8709 6839 11...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/18.in
4,5,12 14,2,10 15,4,11 8,6,2 8,17,10 7,18,16 4,6,9 7,15,17 19,10,13 11,9,1 19,7,11 16,12,6 17,5,12 14,13,19 6,13,3 12,2,9 7,14,3 12,6,3 2,12,7 15,18,9 8,2,12 16,11,4 13,3,5 14,6,17 6,13,15 20,9,14 8,9,20 12,19,11 8,2,13 12,4,4 12,2,11 17,5,10 15,10,3 19,7,14 14,12,18 6,18,7 15,18,12 7,6,4 8,18,17 15,10,16 11,6,3 5,9,17...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/22.py
#!/usr/bin/python3 import sys from decimal import Decimal import math from copy import deepcopy from collections import defaultdict, deque infile = sys.argv[1] if len(sys.argv) > 1 else "22.in" # infile = "example.in" data = open(infile).read() lines = [x for x in data.split("\n")] G, instr = data.split("\n\n") G = G...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/5.in
[T] [Q] [S] [R] [M] [L] [V] [G] [D] [V] [V] [Q] [N] [C] [H] [T] [S] [C] [V] [D] [Z] [Q] [J] [D] [M] [Z] [C] [M] [F] [N] [B] [H] [N] [B] [W] [N] [J] [M] [P] [G] [R] [Z] [Z] [C] [Z] [G] [P] [B] [W] [N] [P] [D] [V] [G] [L] [T] 1 2 3 4 5 6 7 8 ...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/12.py
#!/usr/bin/python3 import sys import math from copy import deepcopy from collections import defaultdict, deque infile = sys.argv[1] if len(sys.argv) > 1 else "12.in" data = open(infile).read().strip() lines = [x for x in data.split("\n")] G = [] for line in lines: G.append(line) R = len(G) C = len(G[0]) E = [[0 ...
0
hf_public_repos/Advent_of_Code
hf_public_repos/Advent_of_Code/2022/10_me.py
with open("10.in") as f: lines = [l.strip() for l in f.read().strip().split("\n")] r = 1 c = 0 signal = 0 crt = [[0 for _ in range(40)] for _ in range(6)] sprite = [0, 1, 2] def get_signal(c, r, signal, crt): c += 1 cr, cc = (c - 1) // 40, (c - 1) % 40 crt[cr][cc] = "#" if cc in sprite else "." r...