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 / 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;
@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 / 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 / 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 / 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 / input.txt
Created January 30, 2016 04:10
Advent of Code - Day 3 with Immutable.js
^^<<v<<v><v^^<><>^^<v<v^>>^^^><^>v^>v><><><<vv^^<^>^^<v^>v>v^v>>>^<>v<^<v^><^>>>>><<v>>^>>^>v^>><<^>v>v<>^v^v^vvv><>^^>v><v<><>^><^^<vv^v<v>^v>>^v^>v><>v^<vv>^><<v^>vv^<<>v>>><<<>>^<vv<^<>^^vv>>>^><<<<vv^v^>>><><^>v<>^>v<v^v<^vv><^v^><<<<>^<>v>^v>v<v<v<<>v<^<<<v>>>>>^^v>vv^^<>^<>^^^^<^^^v<v^^>v<^^v^^>v>^v^^^^>><<v<>v<>^v^<v<>><>^^><<^^<^^>vv<>v^<^v<vv<<<>^>^^>^<>v^^vv<>>v><<<>vvv<>v<>><^<^v<>^vv>^^v<v<v><^<>>vv<^>>^>>vv^v<vv^vv<^<<>>^v^<>^>>>>vv>^^>v>vv>v><^vv^<<v>^<<^^<v<v>vv<v^^<>^^v>^>>v><^<<vv<<v^vv^^^v>>v<<v^><vv^><vv<^vv<<vv^v<<^v<^^v>><<v^>>^^<>v>><<v<>>^^<v>>^^>>vvv^><<<<<^<^vv<^<><v<<>^^^<<<^>^^^<v<<vv>vv<>^<>v<^v>^<<<v<v<v>>^v<>>v<<^<<v<<>^<<<><><>^>>>>^>v^v<<v<v<<>>vv<^vvv^^^^<vv>vv>^v^^v^<v^v><^vv<^vv>v<^>vv<>>^>^><vv<><^>v>^v>vvv<>^>^v<><>vv>><^v^<><><v>>v^v^><^<^>vv>v<^>vvv>v<<<<<^<v<<vv<^^^<<>>^v<vv<^<>v>^<v<>><><>^<<v>v^>^<vv>><><>>^>^>><^<v>^^>^^>^^v^^<^v^^>v^^>>><<><v<v<<v^vv<><><>^<v>^<<^^v^>v>><>^^^><^vvv<^^^^^v><<><v<^^v><><>>^>vv<vvvv<<>>><v<^^^^v<<^><v>^vv<v^^v^vv<^^>^^<v>><<v^>v<^^>^<^
@mistidoi
mistidoi / day-3.js
Last active January 30, 2016 17:16
Advent of Code - Day 3 - Part 2
"use strict";
let _ = require('lodash');
let fs = require('fs');
fs.readFile('input.txt', 'utf8', function (err, input) {
let moves1 = [];
let moves2 = [];
let starting_coords = [0, 0];
File.open("input.txt").readlines.each do |line|
moves_from_file = line.chomp.split("")
moves1 = []
moves2 = []
moves_from_file.each_with_index do |element, index|
if index % 2 == 1
moves1 << element
@mistidoi
mistidoi / using memoize.js
Last active January 26, 2016 05:43
putting it to use!
var memoize;
memoize = function(func) {
var cache;
cache || (cache = {});
return function() {
var key;
key = JSON.stringify(arguments);
if (cache[key]) {
return cache[key];
@mistidoi
mistidoi / arguments.js
Created January 26, 2016 05:26
Demonstrating arguments
showArguments = function () {
console.log(arguments);
}
showArguments("hey", "I","thought", "this", "function", "didn't", "take", "any", "arguments");