Skip to content

Instantly share code, notes, and snippets.

@einarwh
einarwh / aoc19.fsx
Last active December 19, 2023 20:39
Advent of Code 2023 - Day 19: Aplenty - F# version
// Advent of Code 2023. Day 19: Aplenty
// dotnet fsi aoc19.fsx
open System
open System.IO
open System.Text.RegularExpressions
type Part = {
x : int
m : int
@einarwh
einarwh / aoc18.fsx
Created December 19, 2023 18:43
Advent of Code 2023 - Day 18: Lavaduct Lagoon - F# version
// Advent of Code 2023. Day 18: Lavaduct Lagoon
// dotnet fsi aoc18.fsx
open System
open System.IO
type Direction = U | D | L | R
type Pos = { x : int64; y : int64 }
@einarwh
einarwh / aoc17.fsx
Last active December 17, 2023 13:14
Advent of Code 2023 - Day 17: Clumsy Crucible - F# version
// Advent of Code 2023. Day 17: Clumsy Crucible
// dotnet fsi aoc17.fsx
open System
open System.IO
open System.Collections.Generic
module Array2D =
let getRowCount (ary : 'a[,]) = ary.GetLength(0)
let getColumnCount (ary : 'a[,]) = ary.GetLength(1)
@einarwh
einarwh / aoc16.fsx
Last active December 16, 2023 11:17
Advent of Code 2023 - Day 16: The Floor Will Be Lava - F# version
// Advent of Code 2023. Day 16: The Floor Will Be Lava
// dotnet fsi aoc16.fsx
open System
open System.IO
type Dir = N | W | S | E
module Array2D =
let getRowCount (ary : 'a[,]) = ary.GetLength(0)
@einarwh
einarwh / aoc15comp.fsx
Created December 15, 2023 09:34
Advent of Code 2023 - Day 15: Lens Library - F# version with function composition
// Advent of Code 2023. Day 15: Lens Library
// dotnet fsi aoc15.fsx
open System.IO
let readText fileName =
let text = File.ReadAllText fileName
text.TrimEnd()
let getHash s =
@einarwh
einarwh / aoc15.fsx
Last active December 15, 2023 08:23
Advent of Code 2023 - Day 15: Lens Library - F# version
// Advent of Code 2023. Day 15: Lens Library
// dotnet fsi aoc15.fsx
open System.IO
type Op =
| Insert of (string * int)
| Remove of string
let readText fileName =
// Advent of Code 2023. Day 14: Parabolic Reflector Dish
// dotnet fsi aoc14.fsx
open System
open System.IO
module Array2D =
let getRowCount (ary : 'a[,]) = ary.GetLength(0)
@einarwh
einarwh / aoc14.fsx
Created December 14, 2023 11:41
Advent of Code 2023 - Day 14: Parabolic Reflector Dish - F# version
// Advent of Code 2023. Day 14: Parabolic Reflector Dish
// dotnet fsi aoc14.fsx
open System
open System.IO
let readLines =
File.ReadAllLines >> Array.filter ((<>) String.Empty)
let rollNorthStep (s1, s2) =
@einarwh
einarwh / aoc13.fsx
Last active December 13, 2023 08:54
Advent of Code 2023 - Day 13: Point of Incidence - F# version
// Advent of Code 2023. Day 13: Point of Incidence
// dotnet fsi aoc13.fsx
open System
open System.IO
let readChunks fileName =
let text = File.ReadAllText fileName
text.TrimEnd().Split("\n\n") |> Array.toList
@einarwh
einarwh / aoc12.fsx
Last active December 12, 2023 16:42
Advent of Code 2023 - Day 12: Hot Springs - F# version
// Advent of Code 2023. Day 12: Hot Springs
// dotnet fsi aoc12.fsx
open System
open System.IO
let parseLine (s : string) =
let parts = s.Split(" ")
let springs = parts[0]
let damaged = parts[1]