From: Brendan Hansen Date: Sat, 20 Nov 2021 01:16:49 +0000 (-0600) Subject: initial commit X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=4f3843c78b06bedb2d5149c0cfc933ae37985ac3;p=onyx-aoc-2019.git initial commit --- 4f3843c78b06bedb2d5149c0cfc933ae37985ac3 diff --git a/day01.onyx b/day01.onyx new file mode 100644 index 0000000..e6222b9 --- /dev/null +++ b/day01.onyx @@ -0,0 +1,25 @@ +#load "core/std" + +use package core + +main :: (args) => { + reader, stream := io.reader_from_string(#file_contents "./inputs/day01.txt"); + defer cfree(stream); + + sum: i64 = 0; + while !io.stream_end_of_file(stream) { + num: i64 = io.read_u64(^reader); + + calculate_fuel :: macro (n) => math.max((n / 3) - 2, 0); + + while num != 0 { + num = calculate_fuel(num); + sum += num; + } + + io.skip_whitespace(^reader); + } + + printf("Sum is {}\n", sum); +} + diff --git a/day02.onyx b/day02.onyx new file mode 100644 index 0000000..bbbfacd --- /dev/null +++ b/day02.onyx @@ -0,0 +1,37 @@ +#load "core/std" +#load "./intcode" + +use package core +use package intcode + +run_prog :: (ic, n, v) => { + cloned_ic := ic->clone(); + defer cloned_ic->free(); + + cloned_ic.data->set(1, ~~n); + cloned_ic.data->set(2, ~~v); + + for v: (cloned_ic->run()).state --- + return cloned_ic.data->get(0); +} + +main :: (args) => { + ic := IntCode.make(); + + code := #file_contents "./inputs/day02.txt"; + ic->load_code(code); + + printf("Part 1 is {}\n", run_prog(^ic, 12, 2)); + + sln_n, sln_v: u32; + for n: 0..100 { + for v: 0..100 { + if run_prog(^ic, n, v) == 19690720 { + sln_n, sln_v = n, v; + break break; + } + } + } + + printf("Part 2 is {}\n", sln_n * 100 + sln_v); +} diff --git a/day03.onyx b/day03.onyx new file mode 100644 index 0000000..d91c9aa --- /dev/null +++ b/day03.onyx @@ -0,0 +1,88 @@ +#load "core/std" + +use package core + +Point :: struct { x, y: i32; steps: u32 = 0xffffffff; } + +#match hash.to_u32 enc_point +enc_point :: macro (p: Point) => p.x * 1000 + p.y; + +#operator == macro (p1: Point, p2: Point) => p1.x == p2.x && p1.y == p2.y; + +manhattan :: (x, y) => math.abs(x) + math.abs(y); + +main :: (args) => { + reader, stream := io.reader_from_string(#file_contents "./inputs/day03.txt"); + defer cfree(stream); + + points := set.make(Point); + + line1 := io.read_line(^reader) |> string.strip_trailing_whitespace(); + dirs1 := string.split(line1, #char ","); + defer memory.free_slice(^line1); + defer memory.free_slice(^dirs1); + + px, py : i32; + px, py = 0, 0; + steps := 0; + for dir: dirs1 { + direction := dir[0]; + amount := cast(u32) conv.str_to_i64(dir.data[1 .. dir.count]); + + step :: macro (count: i32, dx: i32, dy: i32) { + for _: count { + if !set.has(^points, Point.{ px, py }) { + points << Point.{ px, py, steps }; + } + + px += dx; + py += dy; + steps += 1; + } + } + + switch direction { + case #char "L" do step(amount, -1, 0); + case #char "R" do step(amount, 1, 0); + case #char "D" do step(amount, 0, 1); + case #char "U" do step(amount, 0, -1); + } + } + + line2 := io.read_line(^reader) |> string.strip_trailing_whitespace(); + dirs2 := string.split(line2, #char ","); + defer memory.free_slice(^line2); + defer memory.free_slice(^dirs2); + + minimum_dist := 0xffffffff; + + px, py = 0, 0; + steps = 0; + for dir: dirs2 { + direction := dir[0]; + amount := cast(u32) conv.str_to_i64(dir.data[1 .. dir.count]); + + step :: macro (count: i32, dx: i32, dy: i32) { + for _: count { + if px != 0 || py != 0 { + if set.has(^points, .{ px, py }) { + minimum_dist = math.min(minimum_dist, steps + set.get(^points, .{ px, py }).steps); + } + } + + px += dx; + py += dy; + steps += 1; + } + } + + switch direction { + case #char "L" do step(amount, -1, 0); + case #char "R" do step(amount, 1, 0); + case #char "D" do step(amount, 0, 1); + case #char "U" do step(amount, 0, -1); + } + } + + println(minimum_dist); +} diff --git a/day04.onyx b/day04.onyx new file mode 100644 index 0000000..05c5f45 --- /dev/null +++ b/day04.onyx @@ -0,0 +1,57 @@ +#load "core/std" + +use package core + +hasdouble :: (n) => { + lastdig := -1; + potential_success := false; + inrow := 0; + + while n > 0 { + dig := n % 10; + if dig == lastdig { + inrow += 1; + potential_success = inrow == 1; + if n < 10 do return potential_success; + + } else { + if potential_success do return true; + potential_success = false; + inrow = 0; + } + + n /= 10; + lastdig = dig; + } + + return false; +} + +increasing :: (n) => { + lastdig := 10; + while n > 0 { + dig := n % 10; + if dig > lastdig do return false; + + n /= 10; + lastdig = dig; + } + + return true; +} + +main :: (args) => { + reader, stream := io.reader_from_string(#file_contents "./inputs/day04.txt"); + defer cfree(stream); + + minimum := io.read_u32(^reader); + io.read_byte(^reader); // - + maximum := io.read_u32(^reader); + + count := 0; + for value: minimum .. maximum + 1 { + if hasdouble(value) && increasing(value) do count += 1; + } + + println(count); +} diff --git a/day05.onyx b/day05.onyx new file mode 100644 index 0000000..b85fb81 --- /dev/null +++ b/day05.onyx @@ -0,0 +1,22 @@ +#load "core/std" +#load "./intcode" + +use package core +use package intcode + +main :: (args) => { + ic := IntCode.make(); + defer ic->free(); + + ic->load_code(#file_contents "./inputs/day05.txt"); + + // Part 1 + // ic.input_queue << 1; + + // Part 2 + ic.input_queue << 5; + + for v: (ic->run()).state { + println(v); + } +} diff --git a/day06.onyx b/day06.onyx new file mode 100644 index 0000000..3d153d6 --- /dev/null +++ b/day06.onyx @@ -0,0 +1,97 @@ +#load "core/std" + +use package core +use package core.intrinsics.onyx + +Graph :: struct { + // key orbits value + orbits := do { return map.make(str, str); }; + + // key is orbited by values + inverse_orbits := do { return map.make(str, #type [..] str); }; +} + +graph_make :: macro () => init(Graph); + +part_one :: (graph) => { + Processing :: struct { node: str; depth: u32; } + p := array.make(Processing); + defer array.free(^p); + + p << .{ "COM", 0 }; + + count := 0; + while p.count != 0 { + v := p[0]; + array.fast_delete(^p, 0); + + count += v.depth; + if map.has(^graph.inverse_orbits, v.node) { + for orbiter: graph.inverse_orbits[v.node] { + p << Processing.{ orbiter, v.depth + 1 }; + } + } + } + + printf("Part 1 is {}\n", count); +} + +get_common_parent :: (graph, n1, n2) => { + n1_depth := 1; + n1_parent := graph.orbits[n1]; + + while n1_parent.count > 0 { + n2_depth := 1; + n2_parent := graph.orbits[n2]; + + while n2_parent.count > 0 { + if n1_parent == n2_parent do return n1_parent, n1_depth + n2_depth; + + n2_depth += 1; + n2_parent = graph.orbits[n2_parent]; + } + + n1_depth += 1; + n1_parent = graph.orbits[n1_parent]; + } + + return null_str, -1; +} + +part_two :: (graph) => { + common, depth := get_common_parent(graph, "YOU", "SAN"); + + printf("Part 2 is {}:{}\n", common, depth - 2); +} + +main :: (args) => { + R :: package core.string.reader + + // Using the string reader because it prevents needing to allocate + // the space for each line. + reader := R.make(#file_contents "./inputs/day06.txt"); + + graph := graph_make(); + + while !R.empty(^reader) { + line := R.read_line(^reader); + + orbited := string.read_until(^line, #char ")"); + string.advance(^line, 1); + orbiter := line; + + map.put(^graph.orbits, orbiter, orbited); + if map.has(^graph.inverse_orbits, orbited) { + arr := ^graph.inverse_orbits[orbited]; + *arr << orbiter; + + } else { + arr := array.make(str); + arr << orbiter; + graph.inverse_orbits[orbited] = arr; + } + } + + part_one(^graph); + part_two(^graph); +} diff --git a/day07.onyx b/day07.onyx new file mode 100644 index 0000000..04683f8 --- /dev/null +++ b/day07.onyx @@ -0,0 +1,102 @@ +#load "core/std" +#load "./intcode" + +use package core +use package intcode + +run_amplifier :: (amp_code, n, signal) => { + code := amp_code->clone(); + defer code->free(); + + code.input_queue << ~~n; + code.input_queue << ~~signal; + + for v: (code->run()).state do return v; + return 0; +} + +next_perm :: (a: [] $T) { + i: i32 = a.count - 2; + while i >= 0 { + if a[i] < a[i + 1] do break; + i -= 1; + } + + if i < 0 { + middle := a.count / 2; + for n: middle + 1 { + a[n], a[a.count - 1 - n] = a[a.count - 1 - n], a[n]; + } + + } else { + v := a.count - 1; + for d: i+1 .. a.count { + if a[d] < a[i] { + v = d - 1; + break; + } + } + + a[i], a[v] = a[v], a[i]; + + middle := (a.count - 1 - i) / 2; + for n: middle { + a[n + i + 1], a[a.count - 1 - n] = a[a.count - 1 - n], a[n + i + 1]; + } + } +} + +main :: (args) => { + ic := IntCode.make(); + defer ic->free(); + ic->load_code(io.get_contents("./inputs/day07.txt")); + + order := i64.[ 0, 1, 2, 3, 4 ]; + + maximum: i64 = 0; + for i: 120 { + next_perm(order); + + v: i64 = 0; + for i: 5 do v = run_amplifier(^ic, order[i], v); + + maximum = math.max(maximum, v); + } + + printf("Part 1 is {}\n", maximum); + + order = i64.[ 5, 6, 7, 8, 9 ]; + + maximum = 0; + for i: 120 { + next_perm(order); + + running_amplifiers : [5] IntCode; + running_amplifiers_it : [5] Iterator(IntCode.DataType); + for amp: 5 { + running_amplifiers[amp] = ic->clone(); + running_amplifiers[amp].input_queue << order[amp]; + running_amplifiers_it[amp] = (running_amplifiers[amp]->run()).state; + } + + v: i64 = 0; + new_v: i64; + + while true { + for i: 5 { + running_amplifiers[i].input_queue << ~~v; + if #(new_v) << running_amplifiers_it[i] do break break; + + v = new_v; + } + } + + for ^amp: running_amplifiers { + amp->free(); + } + + maximum = math.max(maximum, v); + } + + printf("Part 2 is {}\n", maximum); +} diff --git a/day08.onyx b/day08.onyx new file mode 100644 index 0000000..aea8897 --- /dev/null +++ b/day08.onyx @@ -0,0 +1,76 @@ +#load "core/std" + +use package core + +main :: (args) => { + image_width :: 25 + image_height :: 6 + image_size :: image_width * image_height + + data := #file_contents "./inputs/day08.txt"; + + layer_count := data.count / image_size; + layers := memory.make_slice(str, layer_count); + defer memory.free_slice(^layers); + for layer: layer_count { + layers[layer] = data.data[layer * image_size .. (layer + 1) * image_size]; + } + + print_layer :: (layer) => { + for y: image_height { + println(layer.data[y * image_width .. (y + 1) * image_width]); + } + } + + zero_count, zero_layer: u32; + zero_count, zero_layer = 1000000000, 0; + for i: layer_count { + @Bug // This only works because the (T) -> bool case has a higher precedence than + // the (^T) -> bool case. Otherwise, x would be a pointer to u8 and this would not work. + count := array.count_where(layers[i], (x) => x == #char "0"); + if count < zero_count { + zero_count = count; + zero_layer = i; + } + } + + one_count := array.count_where(layers[zero_layer], (x) => x == #char "1"); + two_count := array.count_where(layers[zero_layer], (x) => x == #char "2"); + printf("Part 1 is {}\n", one_count * two_count); + + + + rendered_image := memory.make_slice(u8, image_size); + memory.set(rendered_image.data, 0, image_size); + defer memory.free_slice(^rendered_image); + + for y: image_height { + for x: image_width { + pos := x + y * image_width; + + for l: layer_count { + switch layers[l][pos] { + case #char "0" { + rendered_image[pos] = #char " "; + break break; + } + + case #char "1" { + rendered_image[pos] = #char "#"; + break break; + } + } + } + } + } + + println("Part 2:"); + for y: image_height { + for x: image_width { + pos := x + y * image_width; + printf("{}", rendered_image[pos]); + } + + print("\n"); + } +} diff --git a/day09.onyx b/day09.onyx new file mode 100644 index 0000000..bfa8a53 --- /dev/null +++ b/day09.onyx @@ -0,0 +1,20 @@ +#load "core/std" +#load "./intcode" + +use package core +use package intcode + +main :: (args) => { + ic := IntCode.make(); + defer ic->free(); + + ic->load_code(#file_contents "./inputs/day09.txt"); + + // Part 1 + // ic.input_queue << 1; + + // Part 2 + ic.input_queue << 2; + + for v: (ic->run()).state do println(v); +} diff --git a/day10.onyx b/day10.onyx new file mode 100644 index 0000000..1f915f6 --- /dev/null +++ b/day10.onyx @@ -0,0 +1,47 @@ +#load "core/std" + +use package core + +gcd :: (a, b) => { + if a < 0 do a = -a; + if b < 0 do b = -b; + + if b == 0 do return a; + return gcd(b, a % b); +} + +ASTEROID :: #char "#" +SPACE :: #char "." + +in_bounds :: (x, y) => x >= 0 && y >= 0 && x < width && y < height; +get_cell :: macro (x, y) => board[x + y * width]; + +Point :: struct { x, y: i32; } +#match hash.to_u32 (p: Point) => p.x * 10000 + p.y; +#operator == (p1, p2: Point) => p1.x == p2.x && p1.y == p2.y; + +cast_ray :: (x, y, dx, dy) => { + while in_bounds(x, y) { + if get_cell(x, y) == ~~ASTEROID { + return true, Point.{ x, y }; + } + + x += dx; + y += dy; + } + + return false, .{ 0, 0 }; +} + +asteroids : Set(Point); +board: [] u8; +width := 0; +height := 0; + +main :: (args) => { + set.init(^asteroids); + + hit, at := cast_ray(10, 10, -1, -2); + println(hit); + println(at); +} diff --git a/day11.onyx b/day11.onyx new file mode 100644 index 0000000..dc10563 --- /dev/null +++ b/day11.onyx @@ -0,0 +1,186 @@ +#load "core/std" +#load "./intcode" + +use package core +use package core.intrinsics.onyx { __initialize } +use package intcode + +clone :: macro ($code: Code) -> #auto { + new_buffer := cast(^typeof #insert code) raw_alloc(context.allocator, sizeof typeof #insert code); + *new_buffer = #insert code; + return new_buffer; +} + +Pos :: struct { x, y: i32; } +#match hash.to_u32 (use p: Pos) => x * 876137632 + y * 61528335; +#operator == (p1: Pos, p2: Pos) => p1.x == p2.x && p1.y == p2.y; + +Robot :: struct { + running_program : RunningIntCode; + + board : ^Board; + + Direction :: enum { Up; Left; Down; Right; } + direction := Direction.Up; + + pos := Pos.{ 0, 0 }; + + init :: (use this: ^Robot, program_to_run: ^IntCode, set_board: ^Board) { + __initialize(this); + + // program := clone(#(program_to_run->clone())); + + program := cast(^IntCode) raw_alloc(context.allocator, sizeof IntCode); + *program = program_to_run->clone(); + + running_program = program->run(); + board = set_board; + } + + free :: (use this: ^Robot) { + running_program.program->free(); + } + + step :: (use this: ^Robot) -> bool { + cell := board->get(pos); + + running_program.program.input_queue << cast(i64) (1 if cell else 0); + + new_color, rotation: i64; + if #(new_color) << running_program.state do return false; + if #(rotation ) << running_program.state do return false; + + board->set(pos, new_color == 1); + + if rotation == 1 do this->rotate_right(); + else do this->rotate_left(); + + switch direction { + case .Up do pos.y -= 1; + case .Left do pos.x += 1; + case .Down do pos.y += 1; + case .Right do pos.x -= 1; + } + + return true; + } + + run :: (use this: ^Robot) do while this->step() --- + + rotate_left :: (use this: ^Robot) { + switch direction { + case .Up do direction = .Left; + case .Left do direction = .Down; + case .Down do direction = .Right; + case .Right do direction = .Up; + } + } + + rotate_right :: (use this: ^Robot) { + switch direction { + case .Up do direction = .Right; + case .Left do direction = .Up; + case .Down do direction = .Left; + case .Right do direction = .Down; + } + } +} + +Board :: struct { + Chunk_Size :: 1 + + chunks: Map(Pos, [] bool); + + make :: () -> Board { + b: Board; + map.init(^b.chunks); + return b; + } + + clear :: (use this: ^Board) { + map.clear(^chunks); + } + + get :: (use this: ^Board, pos: Pos) -> bool { + chunk_pos := Pos.{ pos.x / Chunk_Size, pos.y / Chunk_Size }; + if chunk := ^chunks[chunk_pos]; chunk != null { + return chunk.data[(pos.x % Chunk_Size) + (pos.y % Chunk_Size) * Chunk_Size]; + + } else { + return false; + } + } + + set :: (use this: ^Board, pos: Pos, value: bool) { + chunk_pos := Pos.{ pos.x / Chunk_Size, pos.y / Chunk_Size }; + + chunk := ^chunks[chunk_pos]; + if chunk == null { + new_chunk := memory.make_slice(bool, Chunk_Size * Chunk_Size); + map.put(^chunks, chunk_pos, new_chunk); + chunk = ^chunks[chunk_pos]; + } + + chunk.data[(pos.x % Chunk_Size) + (pos.y % Chunk_Size) * Chunk_Size] = value; + } +} + +render_board :: (board) => { + x0, x1, y0, y1: i32; + + for ^entry: board.chunks.entries { + x0 = math.min(x0, entry.key.x); + y0 = math.min(y0, entry.key.y); + x1 = math.max(x1, entry.key.x); + y1 = math.max(y1, entry.key.y); + } + + board_width := x1 - x0 + 1; + board_height := y1 - y0 + 1; + printf("The board is {} by {}\n", board_width, board_height); + + rendered_board := memory.make_slice(u8, (board_width + 1) * board_height); + memory.set(rendered_board.data, #char " ", (board_width + 1) * board_height); + for line: board_height { + rendered_board[(board_width + 1) * line - 1] = #char "\n"; + } + + for ^entry: board.chunks.entries do if entry.value[0] { + rendered_board[(board_width - 1 - entry.key.x + x0) + (entry.key.y - y0) * (board_width + 1)] = #char "X"; + } + + return rendered_board; +} + +main :: (args) => { + program := IntCode.make(); + program->load_code(#file_contents "./inputs/day11.txt"); + + robot: Robot; + board := Board.make(); + + // Part 1 + { + robot->init(^program, ^board); + defer robot.running_program.program->free(); + + robot->run(); + + printf("Part 1: {}\n", board.chunks.entries.count); + } + + // Part 2 + { + board->clear(); + robot->init(^program, ^board); + defer robot.running_program.program->free(); + + board->set(.{ 0, 0 }, true); + + robot->run(); + + rendered := render_board(^board); + defer memory.free_slice(^rendered); + printf("Part 2:\n{}\n", rendered); + } +} diff --git a/day12.onyx b/day12.onyx new file mode 100644 index 0000000..be3b6fd --- /dev/null +++ b/day12.onyx @@ -0,0 +1,155 @@ +#load "core/std" + +use package core + +V3 :: struct { x, y, z: i32; } +#operator + (v1: V3, v2: V3) => V3.{ v1.x + v2.x, v1.y + v2.y, v1.z + v2.z }; +#operator - (v1: V3, v2: V3) => V3.{ v1.x - v2.x, v1.y - v2.y, v1.z - v2.z }; +#operator * (v1: V3, s : i32) => V3.{ v1.x * s, v1.y * s , v1.z * s }; + +// Comparator for V3 +// component-wise comparator +#operator << (v1: V3, v2: V3) => V3.{ + (-1) if v1.x < v2.x else (1 if v1.x > v2.x else 0), + (-1) if v1.y < v2.y else (1 if v1.y > v2.y else 0), + (-1) if v1.z < v2.z else (1 if v1.z > v2.z else 0), +}; + + +Moon :: struct { + pos := V3.{ 0, 0, 0 }; + vel := V3.{ 0, 0, 0 }; +} + +#match io.write (writer: ^io.Writer, use moon: Moon) { + io.write_format(writer, "pos=<{*}>, vel=<{*}>", ^pos, ^vel); +} + +step_moons :: (moons: ^[..] Moon) { + pairs(moons, #code { + diff := v1.pos << v2.pos; + v1.vel -= diff; + v2.vel += diff; + }); + + each(*moons, #code { it.pos += it.vel; }); +} + +total_energy :: (moons: ^[..] Moon) -> i32 { + energy := 0; + + for ^moon: *moons { + potential := math.abs(moon.pos.x) + math.abs(moon.pos.y) + math.abs(moon.pos.z); + kinetic := math.abs(moon.vel.x) + math.abs(moon.vel.y) + math.abs(moon.vel.z); + energy += potential * kinetic; + } + + return energy; +} + +main :: (args) => { + input := #file_contents "./inputs/day12.txt"; + + moons := array.make(Moon); + + reader, stream := io.reader_from_string(input); + defer cfree(stream); + + while !io.reader_empty(^reader) { + read_pos :: macro (dest: Code) { + io.read_byte(^reader); // < + io.read_byte(^reader); // x + io.read_byte(^reader); // = + + (#insert dest) = io.read_i32(^reader); + + io.read_byte(^reader); + } + + initial_pos: V3; + read_pos(#(initial_pos.x)); + read_pos(#(initial_pos.y)); + read_pos(#(initial_pos.z)); + io.read_byte(^reader); // read the newline + + moons << .{ initial_pos }; + } + + xs := map.make(#type [] Pair(i32), i32); + ys := map.make(#type [] Pair(i32), i32); + zs := map.make(#type [] Pair(i32), i32); + + tmp_arena := alloc.arena.make(context.allocator, 64 * 1024); + tmp_alloc := alloc.arena.make_allocator(^tmp_arena); + defer alloc.arena.free(^tmp_arena); + + repeated := i64.[ -1, -1, -1 ]; + + while i := 0; array.some(repeated, (p) => p < 0) { + defer i += 1; + + if i == 1000 do printf("Part 1: {}\n", total_energy(^moons)); + + encode_axis :: macro (done_idx: i32, dest: Code, pos: Code, vel: Code) { + if repeated[done_idx] < 0 { + step_encoding := memory.make_slice(#type Pair(i32), moons.count, allocator=tmp_alloc); + for i: moons.count { + p := #insert pos; + v := #insert vel; + step_encoding[i] = .{ p, v }; + } + + if v := map.get_ptr(#insert dest, step_encoding); v != null { + repeated[done_idx] = ~~(i - *v); + } else { + map.put(#insert dest, step_encoding, i); + } + } + } + + encode_axis(0, #(^xs), #(moons[i].pos.x), #(moons[i].vel.x)); + encode_axis(1, #(^ys), #(moons[i].pos.y), #(moons[i].vel.y)); + encode_axis(2, #(^zs), #(moons[i].pos.z), #(moons[i].vel.z)); + + step_moons(^moons); + } + + printf("Repeated at: {}\n", repeated); + + output := array.fold(repeated, cast(i64) 1, math.lcm); + printf("Part 2: {}\n", output); +} + + + +pairs :: macro (arr: ^[..] $T, body: Code) { + for i1: 0 .. arr.count - 1 { + for i2: i1 + 1 .. arr.count { + v1 := ^arr.data[i1]; + v2 := ^arr.data[i2]; + + #insert body; + } + } +} + +each :: macro (iterable: $Iterator_Type, body: Code) { + for ^it: iterable { + #insert body; + } +} + +Pair :: struct (T: type_expr) { a, b: T; } +#match hash.to_u32 (x: Pair($T)) => hash.to_u32(x.a) * hash.to_u32(x.b); +#match hash.to_u32 (x: [] Pair($T)) => array.fold(x, 0, (a: Pair($T), b: i32) => b + hash.to_u32(a)); + +#operator == (p1: Pair($T), p2: Pair(T)) => p1.a == p2.a && p1.b == p2.b; +#operator == (p1: [] Pair($T), p2: [] Pair(T)) -> bool { + if p1.count != p2.count do return false; + + for i: p1.count { + if !(p1[i] == p2[i]) do return false; + } + + return true; +} diff --git a/day13.onyx b/day13.onyx new file mode 100644 index 0000000..837cee8 --- /dev/null +++ b/day13.onyx @@ -0,0 +1,94 @@ +#load "core/std" +#load "./intcode" + +use package core +use package intcode + +Point :: struct { x, y: i32; } +#match hash.to_u32 (use p: Point) => hash.to_u32(x) * hash.to_u32(y); +#operator == (p1: Point, p2: Point) => p1.x == p2.x && p1.y == p2.y; + +Display :: #type Map(Point, u8) + +clear_display :: macro () { + printf("\e[2J"); + __flush_stdio(); +} + +render_display :: (display: ^Display) { + clear_display(); + + for ^entry: display.entries { + printf("\e[{};{}H{}", entry.key.y + 1, entry.key.x + 1, entry.value); + } + + __flush_stdio(); +} + +AI_Context :: struct { + display: ^Display; + score: i32; +} + +ai :: (ic: ^IntCode, use ctx: ^AI_Context) { + render_display(display); + printf("\e[10;50H{}", score); + __flush_stdio(); + + clock.sleep(milliseconds=5); + + paddle_x := array.first(display.entries, (x) => x.value == #char "-").key.x; + ball_x := array.first(display.entries, (x) => x.value == #char "O").key.x; + + input := 0; + if paddle_x < ball_x do input = 1; + if paddle_x > ball_x do input = -1; + + ic->push_input(~~input); +} + +main :: (args) => { + display: Display; + map.init(^display); + + ic := IntCode.make(); + defer ic->free(); + + ai_context := new(AI_Context); + ai_context.display = ^display; + + ic.handle_feed_data = ai_context; + ic.handle_feed_input = ai; + + ic->load_code(#file_contents "./inputs/day13.txt"); + ic.data->set(0, 2); + + program := ic->run(); + while true { + x, y, v : i64; + + if #(x) << program.state do break; + if #(y) << program.state do break; + if #(v) << program.state do break; + + if x == -1 && y == 0 { + ai_context.score = ~~v; + + } else { + c: u8; + switch cast(i32) v { + case 0 do c = #char " "; + case 1 do c = #char "$"; + case 2 do c = #char "#"; + case 3 do c = #char "-"; + case 4 do c = #char "O"; + } + + map.put(^display, .{ ~~x, ~~y }, c); + } + } + + print("\n"); + printf("Part 1: {}\n", array.count_where(display.entries, (x) => x.value == #char "#")); + printf("Part 2: {}\n", ai_context.score); +} diff --git a/day14.onyx b/day14.onyx new file mode 100644 index 0000000..e0ac1f3 --- /dev/null +++ b/day14.onyx @@ -0,0 +1,116 @@ +#load "core/std" + +use package core + +Quantified :: struct { + count : i32; + name : str; +} + +Production :: struct { + reactants : [] Quantified; + product : Quantified; +} + +productions: [..] Production; +produces: Map(str, ^Production); + +main :: (args) => { + map.init(^produces); + array.init(^productions); + + R :: package core.string.reader + reader := R.make(#file_contents "./inputs/day14.txt"); + + while !R.empty(^reader) { + line := R.read_line(^reader); + + parts := string.split(line, #char "="); + defer memory.free_slice(^parts); + + string.advance(^parts[1]); + + for ^part: parts do string.strip_whitespace(part); + + ingredients := string.split(parts[0], #char ","); + defer memory.free_slice(^ingredients); + + reactants := memory.make_slice(Quantified, ingredients.count); + + idx := 0; + for ^i: ingredients { + defer idx += 1; + string.strip_whitespace(i); + + parsed := string.split(*i, #char " "); + defer memory.free_slice(^parsed); + + count := conv.str_to_i64(parsed[0]); + name := parsed[1]; + + reactants[idx] = .{ ~~count, name }; + } + + parsed := string.split(parts[1], #char " "); + defer memory.free_slice(^parsed); + + count := conv.str_to_i64(parsed[0]); + name := parsed[1]; + + productions << .{ reactants, .{ ~~count, name } }; + } + + for ^production: productions { + map.put(^produces, production.product.name, production); + } + + leftovers := map.make(str, i64, default=0); + ore_per_fuel := count_ore("FUEL", 1, ^leftovers); + printf("Part 1: {}\n", ore_per_fuel); + + { + trillion :: 1000000000000 + estimate: i64 = 0; + new_estimate := trillion / ore_per_fuel; + + while new_estimate > estimate { + estimate = new_estimate; + map.clear(^leftovers); + t := count_ore("FUEL", estimate, ^leftovers); + new_estimate = (estimate * trillion) / t; + } + + printf("Part 2: {}\n", estimate); + } +} + +count_ore :: (name: str, needed: i64, leftovers: ^Map(str, i64)) -> i64 { + ore_needed := cast(i64) 0; + original_needed := needed; + + // Consume from leftovers first. + needed -= math.min((*leftovers)[name], needed); + map.update(leftovers, name, #code { *it = math.max(*it - original_needed, 0); }); + if needed == 0 do return ore_needed; + + // Basecase + if name == "ORE" do return ~~needed; + + rule := produces[name]; + applications := (needed / ~~rule.product.count) + ~~(1 if needed % ~~rule.product.count != 0 else 0); + + for ^reactant: rule.reactants { + ore_needed += count_ore(reactant.name, applications * ~~reactant.count, leftovers); + } + + // Update leftovers + excess := applications * ~~rule.product.count - ~~needed; + if map.has(leftovers, rule.product.name) { + map.update(leftovers, rule.product.name, #code { *it += excess; }); + } else { + (*leftovers)[rule.product.name] = excess; + } + + return ore_needed; +} + diff --git a/day15.onyx b/day15.onyx new file mode 100644 index 0000000..cdab4ba --- /dev/null +++ b/day15.onyx @@ -0,0 +1,117 @@ +#load "core/std" +#load "./intcode" + +use package core +use package intcode + +Direction :: struct { vel: V2; code: i64; } +directions := Direction.[ + Direction.{ V2.{ 0, -1 }, 1 }, // north + Direction.{ V2.{ 0, 1 }, 2 }, // south + Direction.{ V2.{ -1, 0 }, 3 }, // west + Direction.{ V2.{ 1, 0 }, 4 }, // east +] + + +Robot :: struct { + pos := V2.zero; + direction := directions[random.between(0, 3)]; +} + +main :: (args) => { + ic := IntCode.make(); + defer ic->free(); + + ic->load_code(#file_contents "./inputs/day15.txt"); + + program := ic->run(); + robot := Robot.{}; + + learned := map.make(V2, u8); + map_out_world(^robot, ^learned, ^program); + + printf("Oxygen system position: {}\n", robot.pos); +} + +display_world :: macro () { + print("\e[2J"); + + for ^entry: learned.entries { + printf("\e[{};{}H{}", entry.key.y - min.y + 1, entry.key.x - min.x + 1, entry.value); + } + + printf("\e[{};{}HO", pos.y - min.y + 1, pos.x - min.x + 1); + __flush_stdio(); +} + +map_out_world :: (use robot: ^Robot, learned: ^Map(V2, u8), program: ^RunningIntCode) { + new_direction :: macro () { + direction_changed := false; + for i: directions.count { + cell := (*learned)[pos + directions[i].vel]; + if cell == 0 { + direction = directions[i]; + direction_changed = true; + break; + } + } + + if !direction_changed do direction = directions[random.between(0, 3)]; + } + + min := V2.{ -20, -20 }; + + while true { + display_world(); + clock.sleep(milliseconds = 5); + + program.program->push_input(direction.code); + + state: i64; + if #(state) << program.state do break; + + switch cast(i32) state { + case 0 { + (*learned)[pos + direction.vel] = #char "#"; + new_direction(); + } + case 1 { + (*learned)[pos] = #char "."; + pos += direction.vel; + new_direction(); + } + case 2 { + pos += direction.vel; + (*learned)[pos] = #char "X"; + break; + } + } + + min = V2.component_wise(min, pos, math.min); + } +} + + +V2 :: struct { + x, y: i32; + + zero :: V2.{ 0, 0 }; + axis_x :: V2.{ 1, 0 }; + axis_y :: V2.{ 0, 1 }; + + neg :: (v: V2) => V2.{ -v.x, -v.y }; + + component_wise :: (v1: V2, v2: V2, $f: (i32, i32) -> i32) => V2.{ f(v1.x, v2.x), f(v1.y, v2.y) }; +} + +#operator + (v1: V2, v2: V2) => V2.{ v1.x + v2.x, v1.y + v2.y }; +#operator - (v1: V2, v2: V2) => V2.{ v1.x - v2.x, v1.y - v2.y }; +#operator * (v1: V2, s: i32) => V2.{ v1.x * s , v1.y * s }; +#operator == (v1: V2, v2: V2) => v1.x == v2.x && v1.y == v2.y; + +#match hash.to_u32 (v: V2) => hash.to_u32(v.x) * hash.to_u32(v.y); + + + + + diff --git a/inputs/day01.txt b/inputs/day01.txt new file mode 100644 index 0000000..43d1b32 --- /dev/null +++ b/inputs/day01.txt @@ -0,0 +1,100 @@ +144968 +146267 +93774 +66835 +139920 +65875 +131321 +108023 +115369 +94673 +117989 +127700 +65335 +81728 +57601 +140987 +54606 +91215 +143883 +131858 +91864 +149716 +103598 +118128 +100712 +108947 +146637 +80490 +120895 +52862 +54410 +99435 +85306 +58179 +88679 +71725 +144885 +145211 +129650 +146724 +108649 +95874 +98155 +118901 +142581 +133366 +95823 +87308 +124940 +145709 +118384 +85552 +90275 +136930 +90085 +50895 +146422 +125462 +106267 +131561 +112356 +101503 +101531 +84320 +76950 +51906 +122922 +136102 +104329 +63004 +141827 +134044 +128319 +95080 +90765 +87322 +61905 +65293 +138240 +74660 +55963 +83560 +87871 +106145 +140945 +114416 +99056 +53210 +74577 +120291 +112627 +102146 +54700 +112290 +133848 +113707 +78735 +54557 +79540 +143154 diff --git a/inputs/day02.txt b/inputs/day02.txt new file mode 100644 index 0000000..bcebbfa --- /dev/null +++ b/inputs/day02.txt @@ -0,0 +1 @@ +1,0,0,3,1,1,2,3,1,3,4,3,1,5,0,3,2,6,1,19,2,19,9,23,1,23,5,27,2,6,27,31,1,31,5,35,1,35,5,39,2,39,6,43,2,43,10,47,1,47,6,51,1,51,6,55,2,55,6,59,1,10,59,63,1,5,63,67,2,10,67,71,1,6,71,75,1,5,75,79,1,10,79,83,2,83,10,87,1,87,9,91,1,91,10,95,2,6,95,99,1,5,99,103,1,103,13,107,1,107,10,111,2,9,111,115,1,115,6,119,2,13,119,123,1,123,6,127,1,5,127,131,2,6,131,135,2,6,135,139,1,139,5,143,1,143,10,147,1,147,2,151,1,151,13,0,99,2,0,14,0 diff --git a/inputs/day03.txt b/inputs/day03.txt new file mode 100644 index 0000000..3c9cb44 --- /dev/null +++ b/inputs/day03.txt @@ -0,0 +1,2 @@ +R997,D543,L529,D916,R855,D705,L159,U444,R234,U639,L178,D682,L836,U333,R571,D906,L583,U872,L733,U815,L484,D641,R649,U378,L26,U66,L659,D27,R4,U325,L264,D711,L837,D986,L38,U623,L830,D369,L469,D704,L302,U143,L771,U170,R237,U477,L251,D100,R561,D889,R857,D780,R258,D299,L975,D481,L692,D894,R847,D416,R670,D658,L537,U748,R468,D304,L263,D884,R806,D13,R288,U933,R4,U291,L809,D242,R669,D50,R106,D510,R409,U311,R101,D232,R370,D490,L762,D805,L981,D637,L987,U403,R965,U724,L404,D664,L687,U868,L808,D174,L363,D241,L54,D238,R444,U75,R683,U712,L759,D569,R349,D378,L576,U437,R137,D822,R21,D595,L602,U147,R959,U350,R964,U625,L718,U331,L252,D386,L251,U371,R973,D709,R915,D837,L7,U727,L501,D520,L626,U161,L287,D224,L821,U555,L312,U234,L335,D572,L113,U673,L615,D919,R925,U16,R211,U77,R630,U786,R850,D221,R939,U559,R887,U779,L222,D482,L252,D682,L904,U568,R317,D453,R689,D917,R845,U260,R69,U613,R528,D447,L791,D119,L268,U215,L806,U786,R465,D787,L792,D823,R526,D709,L362,D748,L518,U115,L898,U784,R893,U911,R98,U215,R828,D100,R153,U496,L938,D403,R886,D317,L849,D59,R156,D27,L64,D771,R956,U880,R313,D244,L483,D17,R72,U467,L475,D444,R554,D781,R524,D152,L771,U435,L622,D601,R733,D478,L686,D12,L525,D467,L302,D948,L966,U572,L303,U914,R54,D417,R635,D425,R640,D703,R17,D187,L195,U59,R166,D616,L557,U458,L743,D166,R328,D640,R908,D775,L151,D216,L964,D202,L534,D239,R998,U167,L604,D812,L527,U526,L640,U93,L733,D980,R607,D879,L593,D721,R454,U137,R683,D343,L38,D398,L81,U392,R821,U247,L361,D208,R763,D771,L515 +L1000,D189,L867,U824,L193,D12,R704,U83,R371,D858,L970,D56,R877,D448,R962,U239,R641,D198,L840,D413,R586,D920,R650,U919,R375,D540,L150,U995,R54,D200,R61,D974,R249,U893,R319,U930,R658,U680,R286,D186,R963,U553,L256,U629,L554,U576,R887,U595,R629,D680,L684,U556,L302,U348,R825,D252,L684,U705,L258,D72,R907,U702,L518,U440,R239,U258,R825,U27,L580,D613,R357,D468,R519,U833,L415,D822,L798,U904,R812,U76,R86,U252,R427,U637,L896,U147,L294,U381,R306,U423,L688,D336,R648,U677,L750,D218,L649,D360,R710,D64,R317,U232,R261,D167,L49,D138,L431,D505,L535,U294,L553,U969,L144,U227,R437,D397,R359,U848,L48,D992,R169,D580,L219,D525,R552,U546,R849,D722,R894,D735,L182,U570,R274,D349,R312,U430,R441,U183,R645,D308,L416,U333,L687,U202,L973,D736,R382,U260,L176,D207,R706,U52,L142,D746,L328,D413,R879,D429,L679,D695,L224,D462,R358,D124,L515,D629,L873,D759,L763,U28,R765,D426,L93,U927,L395,U243,L393,D488,L729,U100,R488,D83,R47,U92,L871,D410,R405,D993,R537,D10,L79,D218,L686,D563,L31,U885,L784,D462,L160,U345,R204,U275,R162,U164,R843,D578,R255,D456,L398,U470,L576,D973,L337,D971,R205,U264,R707,U975,L60,U270,R1,U808,R844,D884,L952,D435,L144,D374,R389,D741,R404,D398,R282,D807,L316,U136,L504,U720,R859,D925,L711,U343,L535,D978,R578,U636,L447,D298,R574,U590,L142,D802,L846,D617,L838,U362,R812,U295,L328,U162,L617,D857,L759,D251,L343,U394,R721,U320,R836,U726,L950,D612,R129,U549,L970,D87,L341,D269,L659,U550,R835,D318,L189,U278,R871,D62,R703,U807,L389,U824,R521,D175,L698,U313,L942,D810,L498,U18,R168,D111,R607 diff --git a/inputs/day04.txt b/inputs/day04.txt new file mode 100644 index 0000000..56a3bb7 --- /dev/null +++ b/inputs/day04.txt @@ -0,0 +1 @@ +178416-676461 diff --git a/inputs/day05.txt b/inputs/day05.txt new file mode 100644 index 0000000..35015f1 --- /dev/null +++ b/inputs/day05.txt @@ -0,0 +1 @@ +3,225,1,225,6,6,1100,1,238,225,104,0,1101,65,73,225,1101,37,7,225,1101,42,58,225,1102,62,44,224,101,-2728,224,224,4,224,102,8,223,223,101,6,224,224,1,223,224,223,1,69,126,224,101,-92,224,224,4,224,1002,223,8,223,101,7,224,224,1,223,224,223,1102,41,84,225,1001,22,92,224,101,-150,224,224,4,224,102,8,223,223,101,3,224,224,1,224,223,223,1101,80,65,225,1101,32,13,224,101,-45,224,224,4,224,102,8,223,223,101,1,224,224,1,224,223,223,1101,21,18,225,1102,5,51,225,2,17,14,224,1001,224,-2701,224,4,224,1002,223,8,223,101,4,224,224,1,223,224,223,101,68,95,224,101,-148,224,224,4,224,1002,223,8,223,101,1,224,224,1,223,224,223,1102,12,22,225,102,58,173,224,1001,224,-696,224,4,224,1002,223,8,223,1001,224,6,224,1,223,224,223,1002,121,62,224,1001,224,-1302,224,4,224,1002,223,8,223,101,4,224,224,1,223,224,223,4,223,99,0,0,0,677,0,0,0,0,0,0,0,0,0,0,0,1105,0,99999,1105,227,247,1105,1,99999,1005,227,99999,1005,0,256,1105,1,99999,1106,227,99999,1106,0,265,1105,1,99999,1006,0,99999,1006,227,274,1105,1,99999,1105,1,280,1105,1,99999,1,225,225,225,1101,294,0,0,105,1,0,1105,1,99999,1106,0,300,1105,1,99999,1,225,225,225,1101,314,0,0,106,0,0,1105,1,99999,1008,226,677,224,102,2,223,223,1005,224,329,1001,223,1,223,7,677,226,224,102,2,223,223,1006,224,344,1001,223,1,223,1007,226,677,224,1002,223,2,223,1006,224,359,1001,223,1,223,1007,677,677,224,102,2,223,223,1005,224,374,1001,223,1,223,108,677,677,224,102,2,223,223,1006,224,389,101,1,223,223,8,226,677,224,102,2,223,223,1005,224,404,101,1,223,223,7,226,677,224,1002,223,2,223,1005,224,419,101,1,223,223,8,677,226,224,1002,223,2,223,1005,224,434,101,1,223,223,107,677,677,224,1002,223,2,223,1006,224,449,101,1,223,223,7,677,677,224,1002,223,2,223,1006,224,464,101,1,223,223,1107,226,226,224,102,2,223,223,1006,224,479,1001,223,1,223,1007,226,226,224,102,2,223,223,1006,224,494,101,1,223,223,108,226,677,224,1002,223,2,223,1006,224,509,101,1,223,223,1108,226,677,224,102,2,223,223,1006,224,524,1001,223,1,223,1008,226,226,224,1002,223,2,223,1005,224,539,101,1,223,223,107,226,226,224,102,2,223,223,1006,224,554,101,1,223,223,8,677,677,224,102,2,223,223,1005,224,569,101,1,223,223,107,226,677,224,102,2,223,223,1005,224,584,101,1,223,223,1108,226,226,224,1002,223,2,223,1005,224,599,1001,223,1,223,1008,677,677,224,1002,223,2,223,1005,224,614,101,1,223,223,1107,226,677,224,102,2,223,223,1005,224,629,101,1,223,223,1108,677,226,224,1002,223,2,223,1005,224,644,1001,223,1,223,1107,677,226,224,1002,223,2,223,1006,224,659,1001,223,1,223,108,226,226,224,102,2,223,223,1006,224,674,101,1,223,223,4,223,99,226 diff --git a/inputs/day06.txt b/inputs/day06.txt new file mode 100644 index 0000000..785291e --- /dev/null +++ b/inputs/day06.txt @@ -0,0 +1,1477 @@ +DGS)1HY +FYY)13C +RPN)9C5 +NNV)CVR +BVN)BCH +39R)BPR +43R)CPB +XFB)J3X +LS3)D2Z +8KB)XX5 +MDK)2YB +NFX)8GF +KV6)T6S +ZDP)163 +CM4)453 +FR8)ZV2 +FQG)QXG +ZLY)G8X +81Q)GKB +V33)QBG +BXZ)724 +T4W)XJ4 +BM6)CW1 +W5P)HWD +3LQ)1BF +7R1)GL2 +1KM)R91 +J19)55D +VW9)PFT +S9F)393 +ZR3)TVM +KM9)K5D +B7P)ZFJ +G2Q)C7N +9C7)QTH +BS2)7NB +5QV)K91 +L1Y)VX5 +PBY)XFL +TC8)B7P +T7C)5WZ +6HZ)NRW +FPT)C75 +FRK)R9F +RXL)WPB +LSG)SYB +WZ5)86T +6NG)C6C +VHQ)P2S +CCN)3PP +Y8H)ZLY +3V6)XBW +GGS)3HX +FK6)VTV +2M1)LNP +3WK)BVF +T2W)HRB +C2T)XSR +HVF)N5T +MPK)X68 +X1H)HXJ +SD1)CG7 +ZLL)T4W +VHS)2G7 +HKC)CJF +DW1)F82 +LWP)C3M +7KH)S8C +TTP)BVM +JCM)3HJ +RBT)9XB +7CG)7B6 +Y8B)MX2 +724)Z38 +6V6)TR7 +6CP)67M +DNV)9MG +Q83)2BQ +KX1)MJC +HDT)RSV +HG6)9NW +Y74)S14 +N56)NRN +G8P)XH4 +VK7)R7C +CB5)S7X +NFW)P89 +8VG)RLN +GJB)JYR +BQX)G73 +TWQ)Y74 +K57)DGD +NLY)1SZ +VF8)BTV +JGX)489 +MYZ)LVD +WXN)DJR +6G2)2BG +3M5)J4S +7BD)F3Q +W8M)6FC +6J4)4DD +7Y1)1P7 +GMJ)46H +G5C)V86 +147)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XZY +B7M)XS3 +9DJ)7K5 +DFL)F85 +MJV)DTN +8LL)7T3 +HDT)TCD +4Y4)2WP +GKB)QWF +98M)FNX +2ZW)81Q +4Z7)1FY +GXR)QJK +5YG)T49 +C3M)R8R +4XK)P77 +GMK)GGS +5BH)T9Q diff --git a/inputs/day07.txt b/inputs/day07.txt new file mode 100644 index 0000000..2c69d6f --- /dev/null +++ b/inputs/day07.txt @@ -0,0 +1 @@ +3,8,1001,8,10,8,105,1,0,0,21,38,55,64,89,114,195,276,357,438,99999,3,9,101,3,9,9,102,3,9,9,1001,9,5,9,4,9,99,3,9,101,2,9,9,1002,9,3,9,101,5,9,9,4,9,99,3,9,101,3,9,9,4,9,99,3,9,1002,9,4,9,101,5,9,9,1002,9,5,9,101,5,9,9,102,3,9,9,4,9,99,3,9,101,3,9,9,1002,9,4,9,101,5,9,9,102,5,9,9,1001,9,5,9,4,9,99,3,9,102,2,9,9,4,9,3,9,101,2,9,9,4,9,3,9,102,2,9,9,4,9,3,9,101,2,9,9,4,9,3,9,102,2,9,9,4,9,3,9,1002,9,2,9,4,9,3,9,101,1,9,9,4,9,3,9,101,1,9,9,4,9,3,9,1001,9,1,9,4,9,3,9,1002,9,2,9,4,9,99,3,9,1002,9,2,9,4,9,3,9,1001,9,1,9,4,9,3,9,102,2,9,9,4,9,3,9,102,2,9,9,4,9,3,9,101,2,9,9,4,9,3,9,1002,9,2,9,4,9,3,9,102,2,9,9,4,9,3,9,101,1,9,9,4,9,3,9,102,2,9,9,4,9,3,9,1002,9,2,9,4,9,99,3,9,101,2,9,9,4,9,3,9,101,2,9,9,4,9,3,9,102,2,9,9,4,9,3,9,102,2,9,9,4,9,3,9,1001,9,1,9,4,9,3,9,102,2,9,9,4,9,3,9,101,2,9,9,4,9,3,9,101,1,9,9,4,9,3,9,1001,9,1,9,4,9,3,9,1001,9,2,9,4,9,99,3,9,1001,9,1,9,4,9,3,9,1002,9,2,9,4,9,3,9,1001,9,2,9,4,9,3,9,101,1,9,9,4,9,3,9,101,1,9,9,4,9,3,9,102,2,9,9,4,9,3,9,1002,9,2,9,4,9,3,9,102,2,9,9,4,9,3,9,1002,9,2,9,4,9,3,9,101,1,9,9,4,9,99,3,9,1002,9,2,9,4,9,3,9,1001,9,1,9,4,9,3,9,101,2,9,9,4,9,3,9,1002,9,2,9,4,9,3,9,101,1,9,9,4,9,3,9,101,2,9,9,4,9,3,9,1001,9,1,9,4,9,3,9,1002,9,2,9,4,9,3,9,102,2,9,9,4,9,3,9,1001,9,1,9,4,9,99 diff --git a/inputs/day08.txt b/inputs/day08.txt new file mode 100644 index 0000000..488b039 --- /dev/null +++ b/inputs/day08.txt @@ -0,0 +1 @@ +222222212022222202222222222220122222222020212222021202220200222202221222002222221222022202220222020222222222222222022222222222212222222222222201222222222222212222222222222222222221222222222122212222121212222220202212221222212222221222022222220222021222222222222222222222222222212222222222222201222222222222222122222222222222222220122222222122212222022212220222222202220222222222222222122212222222021222222222222222022222222222202221222222222200222222222222212022222222222222222221202222222121222222022202221200222202220222112222222222222212222222021222222222222222022222222222222222222222222212222222222222212122122212222222222222212222222022212222120212222202202222220222022222220222222222220222222222222222222222022222222222222221222222222221222222222222212222222212222222222222122222222222212222120212221211212202221222222222222222222212222222022222222222222222022222222220202220222222222220222222222222222222222222222222222222112222222121222222121222221220212222221222012222222222221222222222220222222222222222222222222221222221222222222212222222222222212122122202222222222221002222222021212222021222022211112222222222102222221222221222222222021222222222222222022222222222212220222222222210222222222222222022022222222222222222012222222020212222022212121222222202220222202222220222022212220222220222222222222222222222222221212222222222222210222222222222202022022222222222222222012222222022222222122212020211212212220222012222221222222212221222020222222222222222122222222220212221222222222202222222222222222022022222222222222221212222222020212122022212220211102222221222212222222222221212221222121222222222222222122222222220222220222222222220222222222222222222022212222222222221002222222122222022221202021212012212221222122222221222121202222222122222222222222222222222222222202221222222222220222222222222222222122202222222222220112222222221222022122202022210002212222222022222220222220212221222021222222222222222222222222221212220222222222201222222222222212222022202222222222221102222222222202122120222122210112222222222122222221222112222220222221222222222202222222222222220222222222222222220222222222222212122122202222222222220202222222222202122120212020221012212222222022222222222101202220222020222222222212222022222222221202221222222222200222222222222212022222212222222222222002222222022212022220222021221102202221222112222221222001202221222220222222222202222022022222222202222202222222220221222222222212022122212222222222222212222222122222122120222121202002202221222022222222222022202220222020222222222202222222222222222202220222222222212221222222222212222022212222222222221212222022022202222122222220212012222221222222222220222021212221222020222222222212222022222222222222221202222222201222222222222212122222222222222222220112222222022202222221212021212102212221222112222222222001222222222022222220222202222222022222222202220222222222212221222222222212222222222222222222221222222222220202022120212021200202202222222002222221222101222222222022222221222222222222022222221212220202222222201220212222222202122022212222222222221202222022021222222121222121200212212221222102222220222101222221222022222220222222222022022222221202222222222222201222222222222212122022212222222222222012222222221202122222222020212102202222222222222220222100202221222020222222222202222022222222222202220222222222211221212222222222122222202222222222220202222122020202022122202220211012212220222002122221222022212221222220222222222202222022222222222222220212222222212220212222222212022122202222222222222102222222122202222221012222211002222222222012122222222211222220222122222222222212222222222222222202222212222222221220212222222212022022222222222222222212222022120222022220202022022202202221222212122222222201202221222222222222222212222022122222222222221212222222200220222222222222022022212222222222222202222122222212022221202221122122222221222012122221222001212221222221222220222212022022222222222212222222222222221222212222222210022122212222222222221112222222022212002020222021121102222222222222122220222201212221222221222221222222222122122222221222220212222222200222202222222200222122212222222222222112222022220222022221122120101012222220222202122221222110212222222221222222222222122222222122220212222102222222210220202222222211222222202222222222220122222222120222212020112120122222222221222112102220222100222220222121222221222222222122022122222212222202222222211221112222222201022022202222222222220012222022021212002220022222222022202222222000122220222112212221222220222221222222222222222222222212220122222222220222012212222221022222222222222222221122222022021002202021202120211102212222222000112221222111222221222020222222222212222222022122222202221102222222212221012222222200022122202202222222222022222122221222102022002220200222202221222122211222222220202222222020222222222212222122222022222212222122222222221220012202022212222122202222222222020102222222122202022021022121220122222220222210211222222011222221222122222220222202022022122222220212221112222202220221012212122202122222222212222222222002222222121102022120222020111102212221222120022222222011222220222121222221222212222222122122220212222122222222222220122202020211222022222222022222022122222222222202122220100222201222222222222212001220222211222221222022222221222212022022022022222212222222222002201221212222022220222222212202022222020022222122222102202222111121222122202220222102022222222221212221222221222220222222122122122022221202221112222202222222222212020210122222222202222222221212222222221212112220212021002102222220222221222221222112212221222222222222222202022122222022222212222012222112210220012222021221022020202202222222220212222022122202122220120120012002222222222112211221222102212220222220222222222202222022122020220222222002222022210222102222120202222022222202122222022112222022021202222020210121202102222220222102211220222111202222222022222221222212222022222220222222220122222122221221102002220220022021222222122220221102222022222112212020221020021212212220222010010221222201202220222120222221222202022222022222222212221002222102211222112022220220021222222222222220020112222022220012202022121222211002222220222001012220222101202220222221222221222222122222022122220212220102222222211222002012121212022220202212122210120122222222121222212022201212010212212222222111000221222021202222222121222222222202222222022120222202220022222202201222012002022200221220212222222201120122222122020112212222020011111112202222222122222220222021222221222222222221222212222222222122221222222102222112201221012122121221121022202222022200220102222222220102102222110010222222222222222122001221222211222221222221222220222222222022122200222202220002222022212222212202020221222020202202122200022212222022122022222120102021010012202220222110220222222210212222222220222222222212122222022100220122222222222202210221012002020222221120222212022202221022222222120212202122201002112212202220222001120221222122212221222222222220222222022122222011222202220112222112221221002212021200121120212222022221022022222022122222202021122220012212202221222020220222222011222222222020222220220202122122022220221122220122222002201222112202120211021220202202022220021202222022122112022122001020212102202222222122102221222200202220221120222221220202222022222200220022222012222212220222222202220200022221212212122211222212222222122022222020022200112202102222222122001220222101222221220122222220202212022222222101220112222122222012201220122212020201021022222222022210221022222022022222212222122122020022112220222122000220222002202222221121222222200212202120120200221222220012222222221222222012122212220020202212122202222212222222220102210020021100212002002221222102020222222111222221221022222222222202212220120121220022222222222202220220112212120212021022202202122212020212222122222202022220001010012222112222222012022222222220212221222221222220212212012122120012221112221002222112220222222202021210220222212202022212221222222122022122112022122020120012122222222201211221222200222220222220222221202222112120220120222012222112222012212220012102121221220020222222222210122202222022121012000222211110022002222222222102010221222120222222222121222221210202112221022222221212221222222122221221122212122212221202222222122202021002222222121102102220010112022022002222222200121221222201202220220120222222220202012020020220221112022022222112222221022122222212221202212222022222022212202122221102121121000202220012222220222222001220222202222221221122222220222212022020122010222012221022222202212221002102021222022120202212122210021102222222222112202222011002020012002222222011002220222101202221222220222220211202012022121201222012022112222222221221222112020202122120202222222220222112222122220212102120020000120102212221222222101220222012212222221222222222220202022122121212222222020112222012211222002202020201121110202202022221121202212221121022000121200211212012122221222210200222222101222220221122222222220212002121121000222112022222222202222222202122020220222021212212222202222202212121222002201021021100012002012221222220020221222111202121222220222221210222022222222000222222020212222022201220102022022210121210222212122220121022222121221122000122222221122002102221222221122221222101212222220122222222210212022220221020222122020202222012211220022012022210021111212202022211220222212120121122121020211120120202022220222221201222222212202021121222222220212212212020121101222022120002222122210220112221020221020002212202222221122222202220020202001020110212222002202222222012002222222002212020222221222222221222212121020122222012022012222112202222222021221200120122222202122221020202212220022222111020110112222202212220222012202220222201202222020121222222210212102220110210222202122112222212201221212222120201221110202211122221221212212222121002000220000222122022212221222111021221222212222121120020222220201202202222000011222112221112222122211220112121022222220102212210222202022122212122020202112022201212020212122222222001111220222120212020022120222220200212202122201112221112121012222222211222002012021201122220212220122200122012212020022012201222001211200002202220222021002222222010202122222221220222221212102022220022222102021212222012202222222220121222120101212212222220020022222122220002210220010011221102222221222011201201222012212120220120212220202202012021022121222102221022222022210222022101122212022001200220222220122212222021221102210221202110200122112221222011000210222010212221120222222221212222102121221020220112221202222222222222002002021211022112200201122202122010222021222222022021000121102022022221222000200220222102202120022020212221202221002021111121221212022112222022212220022000120210221120202222122210020022212121222122221020010120220212102222222022200212222010212020220220222022200200222210120002221112022122222222202222012110021202221120210222122220020202212221021102222222112110111112022220222011222201222122222021020020212222200202022211021002222112122222222012210220212011121200220220200202122210121012212222022212110222000200221222222222222121001211222202222122120221210022212201212220020221222022221002222222210220212211020211122001202201022202221121202121121222122221211101011212012221222202110222222202212020121220200021210220022020100210220212022212222102212220112022021201022221211221122202220120202121021112210122101210022102102220222210120212222121212221022120221020210222012211021200220022120212222012200220122210022220021100201220122220020022222120022112202020212212121022102220222110120200222201222022100121202221211220222212112022221122220212220012211220110122022220221112201201122211120122222021220112210120021121121212012222222100111222222110202221010020201221200220112221022012222002020202221202022220011110120101222001200212122200120120222222222012111022002211222222222220222220102221222021222221000220220221221201102222120011222222222202222022021222111001121011120002222210022202022111202021121122112122002000012102222222222120101201222212202222121021201121222211022220120111222022120222221022112222001000020222020221221202222212222202202220220112121220200201012012112221222001211221202012212220211021221220202202102022001010220002022112220112011212202212020212222020210220222211022020212022122022021121210022211022212220222020020201222022202020221020022122221210122101000111222212122202222202110202200020121221120100200202022202222010222120010002212222210100222112012221222022210220202100212220210021200222211221212020001112222202221202222102001200101201022102121211200210022201022202212002101102010220122020011002102220222010010200202202222120210022012222201210202121211202222102122102220002121020102012120102212010212200022212010110202020020122221121112120021022122221222202201220222220202220120020122122222201022121021122222022222102220202211002020020120001222020212220122212001222222101210122200120212101112212012221222201020212212200222120201222021021200201022122200111221222222112221022201102110102122201202110210222222222210011212112110012202220111121102212102221222110000201202021210120122022000222200221102221020110220222122112221112212000222200222202121022201221222211120200222020002112012120210211121112002221222000011210222221220021112020221122202222222221021002221102121022221002201020111110220121122112202202222222100222201200021102220022021021220102201212222012001202222101211121010120211222210220202221221222220002021202220002102002212111120122122101212211022221202120221020211020000022220101202222011221222012112220212002211021011121210220220200102212222200220002122102221122000022221021020110211121222211122202111122221212100202202022120200220122220201222002012212202212102022002222022220200210022010110002221112220122202122221222010101122002202110221220022222012021221102001222220022212001022112210222222221211202202210112120010221111021210222222001012020221012122112201112110011201212121202001122210202222210010101220120200000211122121102020112001222222221212222222212012122202222202122211220112210201021222212020022201022010221202111020220221120212220022202010200211111111202021022022112020122200221222102211222202120210021201121111221201211202011220010222212021222200212202002111201021102120221221221122221220122202002000021220020202020010012102221222102202211222002121220112022122220211212012010220220221202221222212012001201221220122221201211220211022212221221220200112112121121110020121112120212220020111221202210102222020021002120221220022212201200221012022022221212111101102011021111122200211220222212200210201111002112011120220202021022011200220210120211222012202021211222011220210201102220021111220122120122202202111201002021221101122001220221222222122120201120011010222120010200210012021201220010022210202212000121022121121022211211002000010111220102021102222012011020002000222022201010220220022200000200202112100202012022201222220012000221222020002221202221022220020221201221202212202122122120221022122202221202101101101100120000211211220201020201211112100100012011222022022021202102101221221221020212212001200121220120002020200220202122001200221012222212212202011211112011202102120022121100202012220020012012000220111002000101210210021102010222011121010222001201201101121112101112220200112102000201101210120111222120022 diff --git a/inputs/day09.txt b/inputs/day09.txt new file mode 100644 index 0000000..cc65a3c --- /dev/null +++ b/inputs/day09.txt @@ -0,0 +1 @@ +1102,34463338,34463338,63,1007,63,34463338,63,1005,63,53,1102,1,3,1000,109,988,209,12,9,1000,209,6,209,3,203,0,1008,1000,1,63,1005,63,65,1008,1000,2,63,1005,63,904,1008,1000,0,63,1005,63,58,4,25,104,0,99,4,0,104,0,99,4,17,104,0,99,0,0,1101,0,0,1020,1101,34,0,1004,1101,0,26,1008,1102,1,37,1011,1101,39,0,1018,1102,587,1,1022,1101,1,0,1021,1102,22,1,1012,1101,0,33,1014,1101,24,0,1016,1101,0,752,1029,1101,36,0,1002,1101,35,0,1006,1101,32,0,1009,1102,38,1,1003,1102,584,1,1023,1101,0,20,1001,1102,892,1,1025,1102,29,1,1000,1101,411,0,1026,1102,1,901,1024,1101,0,761,1028,1101,23,0,1017,1102,30,1,1013,1101,0,27,1015,1102,28,1,1005,1101,408,0,1027,1101,25,0,1007,1102,31,1,1019,1101,0,21,1010,109,5,1207,-2,39,63,1005,63,199,4,187,1105,1,203,1001,64,1,64,1002,64,2,64,109,12,21102,40,1,-1,1008,1016,40,63,1005,63,229,4,209,1001,64,1,64,1106,0,229,1002,64,2,64,109,-5,1207,-5,24,63,1005,63,249,1001,64,1,64,1106,0,251,4,235,1002,64,2,64,109,-14,2102,1,6,63,1008,63,32,63,1005,63,271,1106,0,277,4,257,1001,64,1,64,1002,64,2,64,109,2,1202,1,1,63,1008,63,20,63,1005,63,303,4,283,1001,64,1,64,1106,0,303,1002,64,2,64,109,7,2108,34,2,63,1005,63,319,1106,0,325,4,309,1001,64,1,64,1002,64,2,64,109,6,2101,0,-6,63,1008,63,24,63,1005,63,349,1001,64,1,64,1105,1,351,4,331,1002,64,2,64,109,4,21107,41,42,0,1005,1017,369,4,357,1105,1,373,1001,64,1,64,1002,64,2,64,109,5,21101,42,0,-5,1008,1017,41,63,1005,63,397,1001,64,1,64,1106,0,399,4,379,1002,64,2,64,109,9,2106,0,-4,1106,0,417,4,405,1001,64,1,64,1002,64,2,64,109,-20,21108,43,43,0,1005,1011,435,4,423,1105,1,439,1001,64,1,64,1002,64,2,64,109,-15,2102,1,8,63,1008,63,34,63,1005,63,465,4,445,1001,64,1,64,1105,1,465,1002,64,2,64,109,3,1201,6,0,63,1008,63,28,63,1005,63,491,4,471,1001,64,1,64,1106,0,491,1002,64,2,64,109,18,21108,44,46,0,1005,1017,511,1001,64,1,64,1106,0,513,4,497,1002,64,2,64,109,12,1205,-8,527,4,519,1105,1,531,1001,64,1,64,1002,64,2,64,109,-17,1208,-3,32,63,1005,63,553,4,537,1001,64,1,64,1105,1,553,1002,64,2,64,109,-13,1208,10,31,63,1005,63,573,1001,64,1,64,1105,1,575,4,559,1002,64,2,64,109,17,2105,1,7,1105,1,593,4,581,1001,64,1,64,1002,64,2,64,109,-8,2107,19,-7,63,1005,63,615,4,599,1001,64,1,64,1105,1,615,1002,64,2,64,109,4,1206,8,629,4,621,1106,0,633,1001,64,1,64,1002,64,2,64,109,-2,2101,0,-6,63,1008,63,34,63,1005,63,655,4,639,1105,1,659,1001,64,1,64,1002,64,2,64,109,10,1205,0,671,1105,1,677,4,665,1001,64,1,64,1002,64,2,64,109,-21,2107,26,8,63,1005,63,693,1106,0,699,4,683,1001,64,1,64,1002,64,2,64,109,19,1201,-9,0,63,1008,63,30,63,1005,63,719,1105,1,725,4,705,1001,64,1,64,1002,64,2,64,109,9,1206,-6,741,1001,64,1,64,1106,0,743,4,731,1002,64,2,64,109,-5,2106,0,6,4,749,1001,64,1,64,1105,1,761,1002,64,2,64,109,-14,1202,-1,1,63,1008,63,27,63,1005,63,781,1105,1,787,4,767,1001,64,1,64,1002,64,2,64,109,1,21107,45,44,5,1005,1014,807,1001,64,1,64,1105,1,809,4,793,1002,64,2,64,109,8,21101,46,0,0,1008,1017,46,63,1005,63,835,4,815,1001,64,1,64,1106,0,835,1002,64,2,64,109,-26,2108,20,10,63,1005,63,857,4,841,1001,64,1,64,1106,0,857,1002,64,2,64,109,24,21102,47,1,-5,1008,1010,46,63,1005,63,881,1001,64,1,64,1106,0,883,4,863,1002,64,2,64,109,6,2105,1,3,4,889,1001,64,1,64,1105,1,901,4,64,99,21102,27,1,1,21101,915,0,0,1105,1,922,21201,1,29830,1,204,1,99,109,3,1207,-2,3,63,1005,63,964,21201,-2,-1,1,21101,0,942,0,1105,1,922,21202,1,1,-1,21201,-2,-3,1,21102,1,957,0,1105,1,922,22201,1,-1,-2,1105,1,968,21201,-2,0,-2,109,-3,2106,0,0 diff --git a/inputs/day10.txt b/inputs/day10.txt new file mode 100644 index 0000000..c3f66aa --- /dev/null +++ b/inputs/day10.txt @@ -0,0 +1,25 @@ +#..#.#.#.######..#.#...## +##.#..#.#..##.#..######.# +.#.##.#..##..#.#.####.#.. +.#..##.#.#..#.#...#...#.# +#...###.##.##..##...#..#. +##..#.#.#.###...#.##..#.# +###.###.#.##.##....#####. +.#####.#.#...#..#####..#. +.#.##...#.#...#####.##... +######.#..##.#..#.#.#.... +###.##.#######....##.#..# +.####.##..#.##.#.#.##...# +##...##.######..##..#.### +...###...#..#...#.###..#. +.#####...##..#..#####.### +.#####..#.#######.###.##. +#...###.####.##.##.#.##.# +.#.#.#.#.#.##.#..#.#..### +##.#.####.###....###..##. +#..##.#....#..#..#.#..#.# +##..#..#...#..##..####..# +....#.....##..#.##.#...## +.##..#.#..##..##.#..##..# +.##..#####....#####.#.#.# +#..#..#..##...#..#.#.#.## diff --git a/inputs/day11.txt b/inputs/day11.txt new file mode 100644 index 0000000..8a5faf7 --- /dev/null +++ b/inputs/day11.txt @@ -0,0 +1 @@ +3,8,1005,8,327,1106,0,11,0,0,0,104,1,104,0,3,8,102,-1,8,10,1001,10,1,10,4,10,108,0,8,10,4,10,1001,8,0,28,1006,0,42,2,1104,11,10,1006,0,61,2,1005,19,10,3,8,1002,8,-1,10,1001,10,1,10,4,10,1008,8,1,10,4,10,102,1,8,65,1006,0,4,3,8,1002,8,-1,10,1001,10,1,10,4,10,108,1,8,10,4,10,1002,8,1,89,1,1108,10,10,1,1103,11,10,1,109,18,10,1006,0,82,3,8,102,-1,8,10,1001,10,1,10,4,10,108,0,8,10,4,10,102,1,8,126,2,109,7,10,1,104,3,10,1006,0,64,2,1109,20,10,3,8,1002,8,-1,10,101,1,10,10,4,10,108,1,8,10,4,10,101,0,8,163,3,8,102,-1,8,10,1001,10,1,10,4,10,108,1,8,10,4,10,1002,8,1,185,2,1109,12,10,2,103,16,10,1,107,11,10,3,8,102,-1,8,10,1001,10,1,10,4,10,108,0,8,10,4,10,1001,8,0,219,1,1005,19,10,3,8,102,-1,8,10,1001,10,1,10,4,10,108,1,8,10,4,10,102,1,8,245,2,1002,8,10,1,2,9,10,1006,0,27,1006,0,37,3,8,1002,8,-1,10,1001,10,1,10,4,10,108,0,8,10,4,10,102,1,8,281,1006,0,21,3,8,102,-1,8,10,101,1,10,10,4,10,108,0,8,10,4,10,1001,8,0,306,101,1,9,9,1007,9,1075,10,1005,10,15,99,109,649,104,0,104,1,21102,1,847069852568,1,21101,344,0,0,1105,1,448,21101,0,386979963688,1,21101,355,0,0,1105,1,448,3,10,104,0,104,1,3,10,104,0,104,0,3,10,104,0,104,1,3,10,104,0,104,1,3,10,104,0,104,0,3,10,104,0,104,1,21102,46346031251,1,1,21101,0,402,0,1105,1,448,21102,1,29195594775,1,21101,0,413,0,1105,1,448,3,10,104,0,104,0,3,10,104,0,104,0,21101,0,868498428772,1,21101,0,436,0,1106,0,448,21102,718170641172,1,1,21102,1,447,0,1105,1,448,99,109,2,21202,-1,1,1,21102,40,1,2,21102,1,479,3,21102,1,469,0,1105,1,512,109,-2,2105,1,0,0,1,0,0,1,109,2,3,10,204,-1,1001,474,475,490,4,0,1001,474,1,474,108,4,474,10,1006,10,506,1101,0,0,474,109,-2,2106,0,0,0,109,4,2102,1,-1,511,1207,-3,0,10,1006,10,529,21101,0,0,-3,22101,0,-3,1,22101,0,-2,2,21101,0,1,3,21101,548,0,0,1106,0,553,109,-4,2106,0,0,109,5,1207,-3,1,10,1006,10,576,2207,-4,-2,10,1006,10,576,21202,-4,1,-4,1106,0,644,22101,0,-4,1,21201,-3,-1,2,21202,-2,2,3,21102,1,595,0,1105,1,553,21201,1,0,-4,21101,0,1,-1,2207,-4,-2,10,1006,10,614,21102,1,0,-1,22202,-2,-1,-2,2107,0,-3,10,1006,10,636,22102,1,-1,1,21102,1,636,0,106,0,511,21202,-2,-1,-2,22201,-4,-2,-4,109,-5,2105,1,0 diff --git a/inputs/day12.txt b/inputs/day12.txt new file mode 100644 index 0000000..1d87531 --- /dev/null +++ b/inputs/day12.txt @@ -0,0 +1,4 @@ + + + + diff --git a/inputs/day13.txt b/inputs/day13.txt new file mode 100644 index 0000000..e967e9a --- /dev/null +++ b/inputs/day13.txt @@ -0,0 +1 @@ +1,380,379,385,1008,2367,810138,381,1005,381,12,99,109,2368,1101,0,0,383,1102,0,1,382,21001,382,0,1,20101,0,383,2,21102,37,1,0,1106,0,578,4,382,4,383,204,1,1001,382,1,382,1007,382,36,381,1005,381,22,1001,383,1,383,1007,383,24,381,1005,381,18,1006,385,69,99,104,-1,104,0,4,386,3,384,1007,384,0,381,1005,381,94,107,0,384,381,1005,381,108,1105,1,161,107,1,392,381,1006,381,161,1102,1,-1,384,1106,0,119,1007,392,34,381,1006,381,161,1101,0,1,384,20101,0,392,1,21101,22,0,2,21101,0,0,3,21101,0,138,0,1105,1,549,1,392,384,392,21001,392,0,1,21102,22,1,2,21101,3,0,3,21101,161,0,0,1106,0,549,1101,0,0,384,20001,388,390,1,21001,389,0,2,21102,1,180,0,1106,0,578,1206,1,213,1208,1,2,381,1006,381,205,20001,388,390,1,20101,0,389,2,21101,0,205,0,1106,0,393,1002,390,-1,390,1101,0,1,384,21002,388,1,1,20001,389,391,2,21102,228,1,0,1106,0,578,1206,1,261,1208,1,2,381,1006,381,253,21002,388,1,1,20001,389,391,2,21101,0,253,0,1105,1,393,1002,391,-1,391,1102,1,1,384,1005,384,161,20001,388,390,1,20001,389,391,2,21102,279,1,0,1105,1,578,1206,1,316,1208,1,2,381,1006,381,304,20001,388,390,1,20001,389,391,2,21101,0,304,0,1106,0,393,1002,390,-1,390,1002,391,-1,391,1101,1,0,384,1005,384,161,21002,388,1,1,20102,1,389,2,21102,1,0,3,21102,1,338,0,1105,1,549,1,388,390,388,1,389,391,389,21001,388,0,1,21002,389,1,2,21101,4,0,3,21101,365,0,0,1105,1,549,1007,389,23,381,1005,381,75,104,-1,104,0,104,0,99,0,1,0,0,0,0,0,0,213,16,19,1,1,18,109,3,21202,-2,1,1,22102,1,-1,2,21101,0,0,3,21102,1,414,0,1105,1,549,21201,-2,0,1,21201,-1,0,2,21101,429,0,0,1106,0,601,2101,0,1,435,1,386,0,386,104,-1,104,0,4,386,1001,387,-1,387,1005,387,451,99,109,-3,2106,0,0,109,8,22202,-7,-6,-3,22201,-3,-5,-3,21202,-4,64,-2,2207,-3,-2,381,1005,381,492,21202,-2,-1,-1,22201,-3,-1,-3,2207,-3,-2,381,1006,381,481,21202,-4,8,-2,2207,-3,-2,381,1005,381,518,21202,-2,-1,-1,22201,-3,-1,-3,2207,-3,-2,381,1006,381,507,2207,-3,-4,381,1005,381,540,21202,-4,-1,-1,22201,-3,-1,-3,2207,-3,-4,381,1006,381,529,21201,-3,0,-7,109,-8,2106,0,0,109,4,1202,-2,36,566,201,-3,566,566,101,639,566,566,1202,-1,1,0,204,-3,204,-2,204,-1,109,-4,2105,1,0,109,3,1202,-1,36,594,201,-2,594,594,101,639,594,594,20102,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,78,87,4,94,91,82,96,76,15,73,47,85,6,8,92,7,46,72,68,90,22,78,6,66,1,26,98,85,80,66,95,39,62,81,52,35,98,71,58,8,55,16,93,75,77,47,36,41,91,39,20,97,13,5,31,67,91,96,10,75,7,95,59,43,90,94,25,89,21,66,98,11,2,49,67,25,96,91,72,51,41,47,1,76,30,55,20,5,97,61,73,43,79,13,16,81,1,27,11,96,47,89,48,26,25,34,37,64,13,53,69,41,30,39,93,80,34,75,41,30,42,42,49,68,49,37,40,62,93,77,86,49,72,52,5,78,31,86,86,62,60,56,17,19,80,2,39,49,50,85,63,48,61,95,82,21,18,85,16,86,45,75,28,97,33,21,56,96,40,33,95,69,53,75,47,70,51,80,92,4,54,79,59,42,15,30,86,27,86,63,64,36,27,98,49,58,78,5,16,57,61,32,14,25,51,75,96,93,25,87,20,76,32,96,96,39,84,48,62,82,11,36,1,11,44,71,86,58,4,74,35,3,31,3,27,52,78,96,10,43,16,93,93,61,23,54,90,47,81,70,81,26,89,17,63,60,48,29,77,53,80,80,12,79,80,76,37,80,79,54,17,73,68,15,40,64,81,5,62,74,27,42,72,93,2,21,46,29,76,51,61,13,19,21,96,45,38,47,87,47,67,95,82,56,51,32,1,73,59,83,65,33,92,8,94,14,45,60,20,87,82,1,29,9,15,10,76,90,27,80,30,65,9,79,2,97,41,75,8,68,23,37,19,80,22,15,52,93,79,79,23,61,37,5,88,28,5,44,31,36,20,37,71,45,21,25,16,2,79,28,67,19,47,9,19,64,46,8,88,29,75,65,22,64,32,78,20,88,48,72,90,84,50,59,63,20,86,58,50,97,14,61,10,68,45,81,43,27,95,95,80,91,68,17,83,55,49,41,9,33,51,19,60,54,24,43,68,36,60,5,20,97,14,55,70,35,27,96,80,32,3,63,52,70,31,2,58,3,70,54,35,83,87,83,50,14,97,47,38,44,71,52,3,97,83,24,36,11,45,5,87,21,80,88,98,45,42,37,96,28,42,72,47,39,58,78,23,24,50,78,1,87,81,32,49,21,60,28,33,29,5,38,36,8,59,52,66,67,15,95,87,61,67,80,54,58,36,89,72,96,78,32,58,37,39,76,43,69,20,96,26,71,98,50,36,46,18,68,24,50,43,32,95,70,18,18,66,84,18,13,44,44,6,4,42,37,31,88,18,82,29,41,88,12,96,58,61,72,72,79,80,60,48,15,26,24,29,45,7,36,2,16,31,13,60,13,84,53,4,5,94,52,39,8,14,6,30,70,75,46,13,38,57,24,24,69,51,87,96,65,57,57,14,10,27,97,98,18,4,92,47,6,17,66,93,3,82,83,56,75,82,75,92,35,68,1,43,51,24,13,57,33,87,62,92,38,61,90,1,95,45,4,70,63,34,43,67,5,91,75,23,55,27,70,52,16,78,87,46,2,56,89,88,58,23,95,31,98,96,22,11,61,29,55,77,50,55,96,64,33,14,51,25,47,48,3,15,2,18,63,12,56,47,88,74,32,87,21,74,53,37,93,21,37,9,42,16,39,57,57,59,57,96,88,17,14,5,85,18,40,54,47,80,22,35,84,10,43,91,10,82,85,52,70,69,64,44,93,77,72,80,39,86,20,44,48,24,72,810138 diff --git a/inputs/day14.txt b/inputs/day14.txt new file mode 100644 index 0000000..a8e9529 --- /dev/null +++ b/inputs/day14.txt @@ -0,0 +1,60 @@ +29 PQJGK => 4 SRPZP +6 XKJP, 4 LDSMT => 6 ZVSMJ +9 CGCPW, 2 CFVS => 7 DWZH +1 VQWZC, 1 FRTJG => 1 MGLKL +3 GCTBC, 4 RGKB => 4 RLZR +2 LGLCP => 9 GCTBC +3 DFPW, 12 FRTJG => 2 XVSRT +1 VBXFG => 3 VQWZC +1 GCTBC, 1 BVHM => 8 DGMZB +7 DFPW, 3 JQNL => 7 FRTJG +6 BHQN, 4 VXNP => 5 HBLQT +1 XNBR, 27 FTBNQ, 2 RGKB => 7 JZPMK +6 HKMV, 4 JHDHS, 11 NMSKF => 9 STCX +129 ORE => 5 NVXTP +13 BVHM, 5 XNBR => 3 LKXML +3 SBPM, 4 LDSMT, 13 GPBG => 6 HXFCJ +1 XVSRT, 1 JHDHS => 4 FTBNQ +6 LKXML, 6 HRLWP => 5 PSJK +5 HRLWP, 19 PDHVG => 1 VRQD +3 FTBNQ, 1 QLKTZ => 7 SBPM +2 VXNP => 3 XKJP +4 SRPZP, 7 XVSRT => 8 LMVF +2 GPBG, 8 DWZH, 3 JTCHR, 10 RLZR, 1 CFVS, 20 BFCZ => 2 WZSTV +130 ORE => 9 JQNL +100 ORE => 4 VBXFG +4 XNBR => 8 RDSHN +2 CDBTL, 2 XNBR, 8 QLKTZ => 6 CGCPW +7 CGCPW => 6 BFCZ +7 FTBNQ, 7 VXNP => 1 BVHM +1 HXFCJ, 15 CSXD => 1 DFXPB +1 MCRW, 6 MGLKL, 1 HBLQT => 8 SWRV +19 BZQGL, 10 NMSKF, 20 WZSTV, 15 LVGB, 26 FTBNQ, 45 DWZH, 2 FJWVP, 56 JZPMK => 1 FUEL +12 JTCHR => 4 CDBTL +1 MGLKL => 6 PQJGK +1 NVXTP => 1 LDSMT +3 SWRV, 1 LGLCP => 2 GHVJ +4 DGMZB, 11 HXFCJ, 2 RLZR => 4 SHTB +5 GHVJ, 1 RGKB, 1 GCTBC => 6 HKMV +1 SRPZP => 9 XNBR +1 ZVSMJ => 2 JHDHS +9 SWRV => 5 NMSKF +1 NVXTP => 3 XKBS +7 BHQN => 2 GPBG +21 NMSKF, 12 FTBNQ, 12 SBPM => 3 CMXK +2 GPBG, 12 ZVSMJ, 2 PDHVG => 4 LGLCP +158 ORE => 8 DFPW +3 BVHM, 1 HXFCJ, 5 CGCPW, 5 BFCZ, 6 VRQD, 3 LDSMT => 7 LVGB +1 XVSRT, 1 XKJP => 8 PDHVG +3 VRQD, 16 SHTB, 5 SBPM => 9 BZQGL +1 BVHM, 3 HKMV => 4 CFVS +13 JQNL => 7 VXNP +1 XKJP, 6 XVSRT => 7 MCRW +15 NVXTP, 19 XKBS => 4 BHQN +8 JHDHS, 5 CMXK, 2 GPBG => 8 CSXD +1 JZBR, 13 LKXML, 1 HKMV, 9 DFXPB, 3 XKBS, 2 PSJK, 2 LMVF, 15 HRLWP => 7 FJWVP +1 CGCPW, 3 RDSHN => 8 JZBR +24 PQJGK => 5 JTCHR +1 XVSRT, 5 LDSMT => 6 QLKTZ +17 GPBG => 7 RGKB +4 STCX => 1 HRLWP diff --git a/inputs/day15.txt b/inputs/day15.txt new file mode 100644 index 0000000..4e211d1 --- /dev/null +++ b/inputs/day15.txt @@ -0,0 +1 @@ +3,1033,1008,1033,1,1032,1005,1032,31,1008,1033,2,1032,1005,1032,58,1008,1033,3,1032,1005,1032,81,1008,1033,4,1032,1005,1032,104,99,1002,1034,1,1039,102,1,1036,1041,1001,1035,-1,1040,1008,1038,0,1043,102,-1,1043,1032,1,1037,1032,1042,1106,0,124,1002,1034,1,1039,101,0,1036,1041,1001,1035,1,1040,1008,1038,0,1043,1,1037,1038,1042,1105,1,124,1001,1034,-1,1039,1008,1036,0,1041,102,1,1035,1040,1002,1038,1,1043,1002,1037,1,1042,1106,0,124,1001,1034,1,1039,1008,1036,0,1041,1002,1035,1,1040,101,0,1038,1043,1002,1037,1,1042,1006,1039,217,1006,1040,217,1008,1039,40,1032,1005,1032,217,1008,1040,40,1032,1005,1032,217,1008,1039,9,1032,1006,1032,165,1008,1040,3,1032,1006,1032,165,1102,2,1,1044,1105,1,224,2,1041,1043,1032,1006,1032,179,1101,1,0,1044,1106,0,224,1,1041,1043,1032,1006,1032,217,1,1042,1043,1032,1001,1032,-1,1032,1002,1032,39,1032,1,1032,1039,1032,101,-1,1032,1032,101,252,1032,211,1007,0,29,1044,1105,1,224,1101,0,0,1044,1105,1,224,1006,1044,247,102,1,1039,1034,1002,1040,1,1035,1001,1041,0,1036,1002,1043,1,1038,102,1,1042,1037,4,1044,1106,0,0,19,27,41,9,17,87,2,1,91,14,15,99,17,13,40,13,7,33,23,28,7,21,75,15,41,83,18,4,28,1,21,99,3,2,4,60,16,5,16,22,59,18,37,21,62,96,11,63,46,16,27,76,7,36,38,28,53,18,84,52,12,47,25,93,10,57,64,21,41,75,52,9,80,60,21,86,60,21,70,21,13,72,78,22,61,17,28,54,51,93,18,3,87,21,4,98,17,59,2,17,18,71,5,20,16,39,66,18,7,62,15,37,25,52,27,17,15,10,48,11,39,18,20,68,83,22,36,9,3,69,56,64,21,39,93,1,90,18,57,52,14,41,32,57,5,7,72,18,35,66,21,22,88,2,31,52,7,35,25,50,14,35,7,11,92,38,14,66,3,28,84,18,17,48,15,34,40,4,21,92,52,27,5,4,53,65,59,24,88,24,66,88,85,26,8,26,10,64,99,9,44,38,14,26,74,75,24,31,7,6,62,9,57,75,18,22,52,57,15,3,87,21,39,24,12,8,70,8,19,3,89,16,36,15,36,16,30,28,8,89,12,99,98,16,78,24,11,63,87,55,51,19,57,18,28,9,90,15,95,56,57,1,93,77,24,36,14,44,46,25,66,37,23,8,12,10,58,27,66,4,72,1,2,16,91,16,66,26,24,53,25,20,41,8,75,23,2,20,91,19,3,12,32,30,3,33,85,17,21,92,17,1,12,73,9,34,12,85,42,5,69,67,4,87,70,6,49,96,12,5,37,62,54,72,13,52,14,21,84,68,54,22,78,11,93,12,90,55,7,19,44,21,98,4,46,50,27,30,2,99,27,35,8,5,62,1,91,65,12,80,16,17,81,14,73,60,69,24,23,13,74,57,10,26,21,80,60,10,79,3,9,37,77,73,16,10,3,13,95,4,91,65,11,86,16,24,71,22,6,63,90,56,15,64,8,25,46,77,71,24,13,72,96,22,8,15,79,39,19,19,47,14,16,92,69,73,23,76,23,28,60,84,14,54,62,11,8,30,75,44,16,4,30,82,14,80,11,1,70,85,10,14,73,70,9,54,25,26,12,51,23,86,92,18,11,19,74,55,51,10,73,7,13,43,89,5,55,2,18,82,2,14,63,71,28,7,94,61,10,51,8,53,63,22,39,19,79,20,99,2,66,22,7,68,71,17,19,45,10,14,42,99,9,9,13,75,84,14,83,75,19,92,22,47,4,83,18,46,91,22,61,28,6,71,17,10,1,81,6,60,83,21,14,13,71,11,68,73,52,10,25,30,91,6,25,86,89,19,39,18,95,1,52,23,91,20,14,41,91,26,59,16,85,99,4,15,96,51,19,25,51,73,3,48,79,14,14,41,5,17,59,8,51,43,21,15,47,3,28,53,12,22,23,2,94,74,23,53,20,20,98,21,14,46,61,26,6,55,20,69,28,6,41,19,70,48,6,9,32,32,28,20,21,62,22,38,7,90,3,32,24,92,49,23,72,63,17,18,89,85,33,28,23,27,5,42,52,7,54,18,17,21,63,98,8,9,84,31,24,80,70,22,51,28,61,77,6,25,68,66,8,47,22,7,44,26,37,15,28,68,23,18,18,14,34,3,85,99,31,41,53,28,20,43,90,22,13,70,27,27,17,35,48,11,92,4,60,84,4,38,27,25,89,99,74,2,31,63,13,50,1,54,4,59,3,59,2,54,15,37,19,74,45,75,7,84,19,96,72,75,9,34,18,52,23,99,11,45,81,53,7,71,24,80,26,31,11,74,27,57,0,0,21,21,1,10,1,0,0,0,0,0,0 diff --git a/intcode.onyx b/intcode.onyx new file mode 100644 index 0000000..a2fd726 --- /dev/null +++ b/intcode.onyx @@ -0,0 +1,296 @@ +package intcode + +use package core +use package core.intrinsics.onyx { __initialize, __zero_value } + +// Just to make the step code easier to read +// This will probably go away +IntCodeOp :: enum (i32) { + Add :: 1; + Mul :: 2; + + In :: 3; + Out :: 4; + + Jnz :: 5; + Jz :: 6; + + Lt :: 7; + Eq :: 8; + + RelOff :: 9; + + Hlt :: 99; +} + +get_mode :: macro (op, num) => { + val := (cast(i32) op / cast(i32) math.pow(10, num)) % 10; + return val; +} + +SparseArray :: struct (T: type_expr) { + allocator: Allocator; + buckets: Map(u32, [] T); + bucket_size: u32 = 512; + + make :: ($T: type_expr, bucket_size := 512, allocator := context.allocator) -> SparseArray(T) { + sa: SparseArray(T); + sa.allocator = allocator; + sa.bucket_size = bucket_size; + map.init(^sa.buckets); + return sa; + } + + clone :: (use this: ^SparseArray($T)) -> SparseArray(T) { + sa := SparseArray.make(T, bucket_size=bucket_size, allocator=allocator); + for entry: buckets.entries { + map.put(^sa.buckets, entry.key, memory.copy_slice(entry.value, allocator)); + } + + return sa; + } + + free :: (use this: ^SparseArray($T)) { + for entry: buckets.entries { + memory.free_slice(^entry.value, allocator=allocator); + } + + map.free(^buckets); + } + + set :: (use this: ^SparseArray($T), idx: u32, v: T) { + bucket_idx := idx % bucket_size; + hash_idx := idx / bucket_size; + + if map.has(^buckets, hash_idx) { + map.get(^buckets, hash_idx)[bucket_idx] = v; + + } else { + bucket := memory.make_slice(T, bucket_size, allocator=allocator); + bucket[bucket_idx] = v; + map.put(^buckets, hash_idx, bucket); + } + } + + get :: (use this: ^SparseArray($T), idx: u32) -> T { + bucket_idx := idx % bucket_size; + hash_idx := idx / bucket_size; + + if map.has(^buckets, hash_idx) { + return map.get(^buckets, hash_idx)[bucket_idx]; + + } else { + return __zero_value(T); + } + } + + get_ptr :: (use this: ^SparseArray($T), idx: u32) -> ^T { + bucket_idx := idx % bucket_size; + hash_idx := idx / bucket_size; + + if map.has(^buckets, hash_idx) { + return ^map.get(^buckets, hash_idx)[bucket_idx]; + + } else { + return null; + } + } +} + +#operator [] macro (sa: SparseArray($T), idx: u32) -> T { + return sa->get(idx); +} + +#operator ^[] macro (sa: SparseArray($T), idx: u32) -> ^T { + return sa->get_ptr(idx); +} + +#operator []= macro (sa: SparseArray($T), idx: u32, val: T) { + sa->set(idx, val); +} + +RunningIntCode :: struct { + program : ^IntCode; + state : Iterator(IntCode.DataType); +} + +IntCode :: struct { + DataType :: i64; + + data : SparseArray(DataType); + + pc := 0; + relative_offset := 0; + + input_queue : [..] DataType; + + handle_feed_data : rawptr; + handle_feed_input : (^IntCode, rawptr) -> void = null_proc; + + make :: () -> IntCode { + ic: IntCode; + __initialize(^ic); + + ic.data = SparseArray.make(DataType); + + array.init(^ic.input_queue, capacity=256); + + return ic; + } + + clone :: (use this: ^IntCode) -> IntCode { + ic: IntCode; + __initialize(^ic); + + ic.data = data->clone(); + array.init(^ic.input_queue, capacity=256); + + return ic; + } + + free :: (use this: ^IntCode) { + data->free(); + } + + load_code :: (use this: ^IntCode, code: [] u8) { + reader, stream := io.reader_from_string(code); + this->load_code_from_reader(^reader); + cfree(stream); + } + + load_code_from_reader :: (use this: ^IntCode, reader: ^io.Reader) { + i := 0; + while !io.reader_empty(reader) { + data[i] = io.read_i64(reader); + i += 1; + + if io.peek_byte(reader) == #char "," { + io.read_byte(reader); + } + + io.skip_whitespace(reader); + } + } + + push_input :: (use this: ^IntCode, input: DataType) { + input_queue << input; + } + + get_param :: (use this: ^IntCode, offset: i32, mode: u32) -> DataType { + switch mode { + case 0 do return data[cast(i32) data[offset]]; + case 1 do return data[offset]; + case 2 do return data[~~data[offset] + relative_offset]; + } + } + + write_result :: (use this: ^IntCode, offset: i32, mode: u32, value: DataType) { + switch mode { + case 0 do data[~~data[offset]] = value; + case 1 do assert(false, "bad_mode"); + case 2 do data[~~data[offset] + relative_offset] = value; + } + } + + StepResult :: struct { + Kind :: enum { Cont; Out; Hlt; } + kind : Kind; + + value := cast(DataType) 0; + } + + step :: (use this: ^IntCode) -> StepResult { + new_pc := pc; + retval := StepResult.{ .Cont }; + + binop :: macro (op: Code) { + d1 := get_param(this, pc + 1, get_mode(mode_mask, 0)); + d2 := get_param(this, pc + 2, get_mode(mode_mask, 1)); + write_result(this, pc + 3, get_mode(mode_mask, 2), #insert op); + new_pc = pc + 4; + } + + instr := data[pc]; + mode_mask := instr / 100; + + switch op := cast(IntCodeOp) (instr % 100); op { + case .Add do binop(#(d1 + d2)); + case .Mul do binop(#(d1 * d2)); + case .Lt do binop(#(cast(DataType) (1 if d1 < d2 else 0))); + case .Eq do binop(#(cast(DataType) (1 if d1 == d2 else 0))); + + case .In { + while input_queue.count == 0 { + assert(this.handle_feed_input != null_proc, "input feed not set up correctly."); + this->handle_feed_input(this.handle_feed_data); + } + + res := input_queue[0]; + array.delete(^input_queue, 0); + this->write_result(pc + 1, get_mode(mode_mask, 0), res); + new_pc = pc + 2; + } + + case .Out { + out := this->get_param(pc + 1, get_mode(mode_mask, 0)); + retval.kind = .Out; + retval.value = out; + new_pc = pc + 2; + } + + case .Jnz { + cond := this->get_param(pc + 1, get_mode(mode_mask, 0)); + addr := this->get_param(pc + 2, get_mode(mode_mask, 1)); + if cond != 0 { + new_pc = ~~addr; + } else { + new_pc = pc + 3; + } + } + + case .Jz { + cond := this->get_param(pc + 1, get_mode(mode_mask, 0)); + addr := this->get_param(pc + 2, get_mode(mode_mask, 1)); + if cond == 0 { + new_pc = ~~addr; + } else { + new_pc = pc + 3; + } + } + + case .RelOff { + relative_offset += ~~this->get_param(pc + 1, get_mode(mode_mask, 0)); + new_pc = pc + 2; + } + + case .Hlt do retval.kind = .Hlt; + } + + pc = new_pc; + return retval; + } + + // Creates an iterator out of the programs output. + run :: (use this: ^IntCode) -> RunningIntCode { + next :: (use this: ^IntCode) -> (DataType, bool) { + while true { + res := this->step(); + switch res.kind { + case .Cont --- + case .Hlt do return 0, false; + case .Out do return res.value, true; + } + } + + return 0, false; + } + + close :: (use this: ^IntCode) {} + + return .{ + this, + .{ this, next, close } + }; + } +} +