This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Advent of Code 2024. Day 05: Print Queue. | |
// dotnet fsi aoc05.fsx | |
open System | |
open System.IO | |
let trim (input : string) = input.Trim() | |
let split (splitter : string) (input : string) = input.Split(splitter) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Advent of Code 2024. Day 04: Ceres Search. | |
// dotnet fsi aoc04.fsx | |
open System | |
open System.IO | |
module Array2D = | |
let tryGet (a : 'a[,]) (x, y) = | |
let first = y >= 0 && y < a.GetLength(0) | |
let second = x >= 0 && x < a.GetLength(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Advent of Code 2024. Day 03: Mull It Over. | |
// dotnet fsi aoc03.fsx | |
open System | |
open System.IO | |
open System.Text.RegularExpressions | |
type op = Mul of (int * int) | Do | Dont | |
let toOp (m : Match) : op = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Advent of Code 2024. Day 02: Red-Nosed Reports | |
// dotnet fsi aoc02.fsx | |
open System | |
open System.IO | |
let parseReport (s : string) = | |
s.Split() |> Array.toList |> List.map int | |
let isSafe report = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Advent of Code 2024. Day 02: Red-Nosed Reports | |
% gs -DNOSAFER aoc02.ps | |
/read-input | |
{ % fn | |
[ % fn [ | |
exch % [ fn | |
(r) file % [ F | |
{ | |
dup % [ .. F F |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Advent of Code 2024. Day 01: Historian Hysteria | |
// dotnet fsi aoc01.fsx | |
open System | |
open System.IO | |
open System.Text.RegularExpressions | |
let parsePair (line : string) = | |
let pattern = "^(\d+)\s+(\d+)$" | |
let m = Regex.Match(line, pattern) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Advent of Code 2024. Day 01: Historian Hysteria | |
% gs -DNOSAFER aoc01.ps | |
/read-input | |
{ % fn | |
[ % fn [ | |
exch % [ fn | |
(r) file % [ F | |
{ | |
dup % [ .. F F |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
public interface Printer { | |
public void print(PrintStream stream); | |
} | |
public class ChainPrinter implements Printer { | |
private final char _c; | |
private final Printer _next; | |
public ChainPrinter(char c, Printer next) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
public abstract class Printer { | |
protected final PrintStream _stream; | |
public Printer(PrintStream stream) { | |
_stream = stream; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Advent of Code 2023. Day 20: Pulse Propagation. | |
// Convert input file into dot format for rendering with graphviz. | |
// dotnet fsi dotify.fsx <inputfile> <outputfile?> | |
open System | |
open System.IO | |
type Node = | |
| Broadcaster | |
| FlipFlop |