All input and output is done in ASCII. Attempts to ignore CRs ('\r' aka 0x0D aka 015).
Input must exactly conform to the example and puzzle inputs supplied for Day 17.
Input may be terminated as follows:
# aoc2024day18-so.awk | |
# =================== | |
# | |
# A solver for Advent of Code 2024, Day 18, both parts, implemented in pure POSIX awk | |
# | |
# inspired by Ramen (ラーメン) | |
# | |
# # Invocation | |
# | |
# `awk [-P] -f aoc2024day18-so.awk [part1=<number>] [dim=<number>] [inputfile]` |
<Query Kind="Program"> | |
<Namespace>System.Collections.Immutable</Namespace> | |
</Query> | |
#load "../common/aoc-input-util.linq" | |
#load "../common/aoc-input-util2.linq" | |
#load "../common/aoc-parsers.linq" | |
#load "../common/aoc-exec-util.linq" | |
const bool EXAMPLE = false; |
#load "../common/aoc-input-util.linq" | |
#load "../common/aoc-parsers.linq" | |
void Main() | |
{ | |
using (var tr = | |
//OpenDataFile() | |
GetSampleInput() | |
) | |
{ |
% xyz = readcsv('day24.csv'); | |
n1 = 100; | |
n2 = 200; | |
n3 = 300; | |
r1 = xyz(1:3,n1); | |
r2 = xyz(1:3,n2); | |
r3 = xyz(1:3,n3); | |
v1 = xyz(4:6,n1); |
enum Plane { X = 0, Y = 1, Z = 2 } | |
struct DimensionTrajectory | |
{ | |
public DimensionTrajectory(Hailstone h, Plane p) | |
{ | |
Position = p switch { Plane.X => h.pos.X, Plane.Y => h.pos.Y, Plane.Z => h.pos.Z }; | |
Velocity = p switch { Plane.X => h.vel.Dx, Plane.Y => h.vel.Dy, Plane.Z => h.vel.Dz }; | |
} | |
public readonly long Position; |
#load "C:\Users\Stevie-O\Documents\LINQPad Queries\advent-of-code\common\aoc-input-util.linq" | |
#load "C:\Users\Stevie-O\Documents\LINQPad Queries\advent-of-code\common\aoc-parsers.linq" | |
const string EXAMPLE_1 = @" | |
.|...\.... | |
|.-.\..... | |
.....|-... | |
........|. | |
.......... | |
.........\ |
enum RockType { None, Round, Cube } | |
interface IPlatformState | |
{ | |
int Width { get; } | |
int Height { get; } | |
RockType GetRockAt(int row, int col); | |
} |
1101,0,0,3,109,842,21101,822,0,1,21101,832,0,2,21101,21,0,0,1105,1,215,1201,1,0,820,21101,832,0,1,21101,842,0,2,21101,40,0,0,1105,1,215,2008,820,1,45,1106,0,678,21001,822,0,1,21001,832,0,2,21101,62,0,0,1105,1,95,202,1,821,821,101,-1,820,820,101,1,48,48,101,1,52,52,1005,820,47,21001,821,0,1,21101,92,0,0,1105,1,536,104,10,99,109,11,21201,-9,1,-8,22202,-10,-10,-7,22102,-4,-9,-6,22201,-7,-6,1,1207,1,1,118,1105,0,685,21101,127,0,0,1105,1,344,21202,1,-1,-5,22201,-10,-5,1,21101,142,0,0,1105,1,407,21201,1,0,-4,1202,-4,-1,152,21201,-10,0,-3,22202,-4,-3,-2,2207,-2,-8,163,1106,0,172,21201,-4,1,-4,1105,1,146,21201,-3,0,-1,1202,-1,-1,182,21201,-10,0,-3,22202,-1,-3,-2,2207,-2,-8,193,1105,0,202,21201,-1,1,-1,1105,1,176,21202,-4,-1,-10,22201,-1,-10,-10,109,-11,2105,1,0,109,7,21101,0,0,-3,1201,-6,0,293,1101,229,0,304,21101,0,0,-4,21101,0,0,-2,203,-1,1208,-1,10,244,1105,0,269,1207,-1,48,251,1105,0,260,2107,57,-1,258,1106,0,305,1005,1,237,1206,-2,237,1105,1,283,2201,-3,-2,274,1106,0,237,1206,-2,335,1101,335,0,304,2007,293,-5,28 |