Instantly share code, notes, and snippets.

View WordSquares.fsx
let CreateEmptySquare dim = Array.init dim (fun _ -> Array.create dim ' ')
// Needed to remove letters from the available letter set at each step
let MultisetSubtraction (source: 'a[]) (toRemove:'a[]) =
let filterIndex = System.Collections.Generic.Dictionary<'a,int>()
toRemove |> Array.iter(fun c-> if filterIndex.ContainsKey(c) then filterIndex.[c] <-filterIndex.[c] + 1 else filterIndex.Add(c,1))
source |> Array.choose (fun item ->
if filterIndex.ContainsKey(item) && filterIndex.[item] > 0
then
filterIndex.[item] <- filterIndex.[item] - 1
View Presidents.csx
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static LifeBoundary;
/*
* The idea is to use a stack to keep track of how many presidents
* are alive at a given time.
*
View obliques.fsx
type ObliqueKind = Wide | Tall | Square
let (|FirstGreater|FirstLesser|BothEqual|) = function 1 -> FirstGreater | -1 -> FirstLesser | 0 -> BothEqual
let ParseTextInput (input : string ) =
input.Split('\n')
|> Array.where (fun line -> System.String.IsNullOrEmpty(line) |> not )
|> Array.map (fun line -> System.Text.RegularExpressions.Regex.Split(line.Trim(),"\s+") |> Array.map(int))
let TraceObliqueFromStartingPoint rowCount (rowIndex,colIndex) =
View DNAShotgun.fsx
open System.Collections
open System.Collections.Generic
let inline (<+>) (left : string) (right : string) =
if left.Contains(right) then left
elif right.Contains(left) then right
else
let nLeft = left.Length
let rec merge depth =