Skip to content

Instantly share code, notes, and snippets.

Ares Lazarus SpaceAntelope

Block or report user

Report or block SpaceAntelope

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
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
@SpaceAntelope
SpaceAntelope / Presidents.csx
Last active Mar 8, 2016
Paste into a C# Interactive window and press enter.
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.
*
@SpaceAntelope
SpaceAntelope / obliques.fsx
Last active Feb 29, 2016
A bit of a roundabout sort of way of turning a matrix to a set of obliques, and then turning it back to a matrix again
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 =
You can’t perform that action at this time.