This file contains hidden or 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
| open System | |
| open System.IO | |
| let input = | |
| File.ReadAllLines("input06.txt") | |
| |> Seq.toList | |
| |> Seq.toList | |
| let setOperation = | |
| // Set.union // for part 1 |
This file contains hidden or 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
| open System | |
| open System.IO | |
| type BagColor = string * string | |
| type BagQuantity = { | |
| Color : BagColor | |
| Count : int | |
| } |
This file contains hidden or 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
| open System | |
| open System.IO | |
| type Instruction = | |
| | Nop of int | |
| | Acc of int | |
| | Jmp of int | |
| let parseLine (line : string) = | |
| let words = line.Split(' ') |
This file contains hidden or 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
| let input = | |
| File.ReadAllLines("Data/input09.txt") | |
| |> Seq.toArray | |
| |> Array.map Int64.Parse | |
| // Reused from Day 1 | |
| let rec findNwithSum sum n numbers acc_sum acc_numbers = | |
| if sum < 0L || n < 0 then | |
| None | |
| else if sum = 0L && n = 0 then |
This file contains hidden or 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
| // Part 1 | |
| File.ReadAllLines("Data/input10.txt") | |
| |> Seq.toList | |
| |> List.map Int64.Parse | |
| |> List.sort | |
| |> List.fold (fun (last,diff1,diff3) n -> | |
| if n - last = 1L then (n, diff1+1, diff3) else (n, diff1, diff3+1)) (0L,0,1) | |
| // Part 2 |
This file contains hidden or 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
| type SeatStatus = | |
| | Floor | |
| | Empty | |
| | Occupied | |
| let parseStatus ch = match ch with | '.' -> Floor | 'L' -> Empty | _ -> Occupied | |
| let input = | |
| File.ReadAllLines("Data/input11.txt") |
This file contains hidden or 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
| module TwelveOne = | |
| let parseLine (line : string) = | |
| (line.[0],Int32.Parse line.[1..]) | |
| let turn cmd dist dir = | |
| match cmd with | |
| | 'R' -> | |
| match dir with |
This file contains hidden or 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
| module ThirteenOne = | |
| open System | |
| open System.IO | |
| type Schedule = { | |
| Timestamp : int | |
| Buses : int array | |
| } |
This file contains hidden or 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
| module FourteenOne = | |
| open System | |
| open System.IO | |
| open System.Text.RegularExpressions | |
| type Memory = Map<int, uint64> | |
| type Instruction = | |
| | Mask of uint64 * uint64 |
This file contains hidden or 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
| module Sixteeen = | |
| open System | |
| open System.IO | |
| open System.Text.RegularExpressions | |
| type Range = { | |
| Min : int | |
| Max : int | |
| } |