Skip to content

Instantly share code, notes, and snippets.

@einarwh
einarwh / Program.cs
Last active March 29, 2025 13:07
FizzBuzz without numbers
namespace FizzBuzzWithoutNumbers;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
class Program
{
public class EmptyStringEnumerable : IEnumerable<string>
{
@einarwh
einarwh / Program.cs
Created March 29, 2025 08:36
FizzBuzz using nodes in a circle.
namespace FizzBuzzCircular;
using System.Collections;
using System.Collections.Generic;
class Program
{
public class Node
{
private readonly Func<string> _fn;
@einarwh
einarwh / Program.cs
Created March 28, 2025 20:49
FizzBuzz in C# without conditionals
namespace Fizzbuzz;
using System.Collections;
using System.Collections.Generic;
class Program
{
public class FizzBuzzEnumerable : IEnumerable<string>
{
private readonly int n;
@einarwh
einarwh / Program.cs
Last active March 28, 2025 20:41
FizzBuzz using IEnumerable
namespace Fizzbuzz;
using System.Collections;
using System.Collections.Generic;
class Program
{
public class FizzBuzzEnumerable : IEnumerable<string>
{
public IEnumerator<string> GetEnumerator()
@einarwh
einarwh / aoc20.fsx
Created December 20, 2024 19:31
Advent of Code 2024. Day 20: Race Condition.
// Advent of Code 2024. Day 20: Race Condition.
// dotnet fsi aoc20.fsx
open System
open System.IO
open System.Collections.Generic
open System.Diagnostics
module Array2D =
let inBounds (a : 'a[,]) (x, y) =
@einarwh
einarwh / aoc19.fsx
Last active December 20, 2024 09:16
Advent of Code 2024. Day 19: Linen Layout. F# version.
// Advent of Code 2024. Day 19: Linen Layout.
// dotnet fsi aoc19.fsx
open System
open System.IO
open System.Collections.Concurrent
let trim (input : string) = input.Trim()
let split (splitter : string) (input : string) = input.Split(splitter)
@einarwh
einarwh / aoc18.fsx
Created December 18, 2024 23:55
Advent of Code 2024. Day 18: RAM Run. F# version.
// Advent of Code 2024. Day 18: RAM Run.
// dotnet fsi aoc18.fsx
open System
open System.IO
open System.Collections.Generic
type Pos = (int*int)
type PQ = PriorityQueue<Pos * int, int>
@einarwh
einarwh / aoc17.fsx
Last active December 17, 2024 18:13
Advent of Code 2024. Day 17: Chronospatial Computer. F# version.
// Advent of Code 2024. Day 17: Chronospatial Computer.
// dotnet fsi aoc17.fsx
open System
open System.IO
type Computer = {
regA : int64
regB : int64
regC : int64
@einarwh
einarwh / aoc16.fsx
Last active December 16, 2024 21:14
Advent of Code 2024. Day 16: Reindeer Maze. F# version.
// Advent of Code 2024. Day 16: Reindeer Maze.
// dotnet fsi aoc16.fsx
open System
open System.IO
open System.Collections.Generic
module Maze =
let get (a : 'a[,]) (x, y) =
Array2D.get a y x
@einarwh
einarwh / aoc15.fsx
Created December 15, 2024 13:47
Advent of Code 2024. Day 15: Warehouse Woes. F# version.
// Advent of Code 2024. Day 15: Warehouse Woes.
// dotnet fsi aoc15.fsx
open System
open System.IO
module Warehouse =
let inBounds (a : 'a[,]) (x, y) =
let first = y >= 0 && y < a.GetLength(0)
let second = x >= 0 && x < a.GetLength(1)