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
{ | |
"name": "config-api", | |
"version": "1.10.0", | |
"scripts": { | |
"integration-dev": "env TEST_MODE=handler env SERVERLESS_STAGE=dev env SERVERLESS_REGION=eu-west-1 ./node_modules/.bin/mocha test/test_cases -t 60000 --reporter spec", | |
"acceptance-dev": "env TEST_MODE=http env SERVERLESS_STAGE=dev env SERVERLESS_REGION=eu-west-1 ./node_modules/.bin/mocha test/test_cases -t 60000 --reporter spec", | |
"integration-test": "env TEST_MODE=handler env SERVERLESS_STAGE=test env SERVERLESS_REGION=eu-west-1 ./node_modules/.bin/mocha test/test_cases -t 60000 --reporter spec", | |
"acceptance-test": "env TEST_MODE=http env SERVERLESS_STAGE=test env SERVERLESS_REGION=eu-west-1 ./node_modules/.bin/mocha test/test_cases -t 60000 --reporter spec", | |
"integration-staging": "env TEST_MODE=handler env SERVERLESS_STAGE=staging env SERVERLESS_REGION=eu-west-1 ./node_modules/.bin/mocha test/test_cases -t 60000 --reporter spec", | |
"acceptance-staging": "env TEST_MODE=http env SERVERLESS_STAGE=staging env SERVERLESS_REGION |
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'; | |
const co = require('co'); | |
const chance = new require('chance').Chance(); | |
const expect = require('chai').expect; | |
const lib = require('../lib/index'); | |
const when = require('../steps/when'); | |
const region = process.env.SERVERLESS_REGION; | |
describe(`Given there are a few config items`, () => { |
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
let part1 = | |
Seq.initInfinite id | |
|> Seq.find (fun n -> | |
execute [ "a", n ] instructions | |
|> Seq.take 1000 | |
|> Seq.chunkBySize 2 | |
|> Seq.forall (fun [| a; b |] -> a = 0 && b = 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
let execute initValues (instructions : Instruction[]) = | |
let registers = new Dictionary<string, int>() | |
initValues |> Seq.iter (fun (key, value) -> registers.[key] <- value) | |
let fetch = function | |
| Value n -> n | |
| Reg reg -> | |
match registers.TryGetValue reg with | |
| true, n -> n | |
| _ -> 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
open System | |
open System.Collections.Generic | |
open System.IO | |
let inputs = File.ReadAllLines (__SOURCE_DIRECTORY__ + "/Day25Input.txt") | |
type Operant = | |
| Value of int | |
| Reg of string |
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
let part2 = | |
let rec traverse current (nodes : Set<int>) finalDest acc = | |
if nodes.Count = 0 then acc + pairDistances.[current, finalDest] | |
else | |
nodes | |
|> Seq.map (fun next -> | |
let left = nodes.Remove next | |
let dist = pairDistances.[current, next] | |
traverse next left finalDest (acc + dist)) |
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
let part1 = | |
let rec traverse current (nodes : Set<int>) acc = | |
if nodes.Count = 0 then acc | |
else | |
nodes | |
|> Seq.map (fun next -> | |
let left = nodes.Remove next | |
let dist = pairDistances.[current, next] | |
traverse next left (acc + dist)) |
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
let numbers = | |
[| | |
for y = 0 to height-1 do | |
for x = 0 to width-1 do | |
match grid.[x, y] with | |
| Number n -> yield n, (x, y) | |
| _ -> () | |
|] | |
|> Map.ofArray |
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
open System.Collections.Generic | |
let findShortestPath start target = | |
let cache = new HashSet<int*int>([start]) | |
[| (start, 0) |] | |
|> Seq.unfold (fun paths -> | |
paths | |
|> Seq.collect (fun ((x, y), moves) -> | |
[ x-1, y; x+1, y; x, y-1; x, 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
open System.IO | |
let input = File.ReadAllLines(__SOURCE_DIRECTORY__ + "/Day24Input.txt") | |
type Tile = Wall | Space | Number of int | |
let width, height = input.[0].Length, input.Length | |
let grid = Array2D.init width height (fun x y -> | |
match input.[y].[x] with | |
| '#' -> Wall |