This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
let fs = require('fs'); | |
let _ = require("lodash"); | |
class Or { | |
constructor(arg1, arg2) { | |
this.arg1 = arg1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"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)); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
^^<<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<^^>^<^ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"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]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var memoize; | |
memoize = function(func) { | |
var cache; | |
cache || (cache = {}); | |
return function() { | |
var key; | |
key = JSON.stringify(arguments); | |
if (cache[key]) { | |
return cache[key]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
showArguments = function () { | |
console.log(arguments); | |
} | |
showArguments("hey", "I","thought", "this", "function", "didn't", "take", "any", "arguments"); |
NewerOlder