Skip to content

Instantly share code, notes, and snippets.

View mistidoi's full-sized avatar

Brandon Hamilton mistidoi

  • Relevant Healthcare, Inc.
View GitHub Profile
@mistidoi
mistidoi / day25.js
Created February 3, 2016 16:36
Day 25 - Advent of Code
"use strict";
// note: this solution requires Babel, as node doesn't yet support tail call optimization.
let firstColumn = function firstColumn(y, acc = 1) {
if (y == 1) {
return acc;
}
return firstColumn(y - 1, acc + (y - 1));
};
@mistidoi
mistidoi / bcp2csv.hs
Created July 25, 2016 00:30
bsp2csv in Haskell
import System.Environment
import Data.List.Split
import Data.List.Utils
import Data.List
-- usage: $ ./bcp2csv input.txt output.txt
main :: IO ()
main = do
args <- getArgs
input <- readFile $ head args
@mistidoi
mistidoi / bcp2csv.hs
Created July 25, 2016 00:31
bcp2csv in Haskell (with Lazy BtyeStrings)
import System.Environment
import Data.List.Split
import Data.List.Utils
import Data.List
import qualified Data.ByteString.Lazy.Search as S
import qualified Data.ByteString.Lazy.Char8 as C
-- usage: $ ./bcp2csv input.bcp output.csv
main :: IO ()
main = do
@mistidoi
mistidoi / day17.hs
Created August 19, 2016 16:41
Solution to Advent of Code Day 17 in Haskell
import Data.List
main = do
let input = [33,14,18,20,45,35,16,35,1,13,18,13,50,44,48,6,24,41,30,42]
let total = 150
let combinations_summing_to_total = [x | x <- powerSet input, sum x == total]
putStrLn "Solution to part 1:"
print $ length $ combinations_summing_to_total
let minimum_number_of_cups = minimum $ map length combinations_summing_to_total
@mistidoi
mistidoi / day7.js
Created August 19, 2016 16:57
AOC Day 7 in JS
"use strict";
let fs = require('fs');
let _ = require("lodash");
class Or {
constructor(arg1, arg2) {
this.arg1 = arg1;