First, a few dependencies:
- Leiningen: https://leiningen.org/
- Node.js & NPM: https://nodejs.org/
- Serverless: https://serverless.com/
- An active AWS account: https://aws.amazon.com/
(ns my-app.css | |
(:require ["emotion" :as emotion])) | |
(defn edn [& styles] | |
(apply emotion/css (map clj->js styles)) |
#!/usr/local/bin/zsh | |
brew tap railwaycat/emacsmacport | |
brew install emacs-mac --with-xml2 --with-ctags --with-spacemacs-icon --with-gnutls --with-natural-title-bar | |
osascript -e 'tell application "Finder" to make alias file to POSIX file "/usr/local/opt/emacs-mac/Emacs.app" at POSIX file "/Applications"' | |
# For opening from term: https://gist.github.com/railwaycat/4043945 | |
# Install spacemacs | |
git clone https://github.com/syl20bnr/spacemacs ~/.emacs.d |
First, a few dependencies:
module Components = { | |
module Box = { | |
let jsComponent = [%bs.raw | |
{| | |
({ children, ...props }) => React.createElement("box", props, children) | |
|} | |
]; | |
let make = (~width, ~height, ~top, ~left, children) => | |
ReasonReact.wrapJsForReason( | |
~reactClass=jsComponent, |
module StringSet = Set.Make(String); | |
let arrayToStringSet = (arr) => StringSet.of_list(Array.to_list(arr)); | |
let noDuplicates = (cardinal, pass) => { | |
let phrases = Js.String.split(" ", pass); | |
cardinal(arrayToStringSet(phrases)) == Array.length(phrases) | |
}; | |
let part1 = (input) => |
let abs = Js.Math.abs_int; | |
/* | |
Desired output: | |
1 => (0, 0) | |
2 => (1, 0) | |
3 => (1, 1) | |
4 => (0, 1) | |
5 => (-1, 1) | |
6 => (-1, 0) |
let splitLines = (input) => Js.String.split("\n", input) |> Array.to_list; | |
let splitDigits = (line) => | |
Js.String.split("\t", line) |> Array.map(int_of_string) |> Array.to_list; | |
let debug = (input) => { | |
Js.log(input); | |
input | |
}; |
let explode = (input) => | |
Js.String.split("", input) | |
|> Array.map(int_of_string); | |
let rec solver = (digits, len, step, xPos, total) => { | |
let x = digits[xPos]; | |
let yPos = (xPos + step) mod len; | |
let y = digits[yPos]; | |
/* curry the next call to solver */ |
let explode = (input) => | |
Js.String.split("", input) | |
|> Array.map(int_of_string) | |
|> Array.to_list; | |
let solve = (input) => { | |
let len = String.length(input); | |
let step = len / 2; | |
let listInput = explode(input); | |
let nth = List.nth(listInput); |
let explode = (input) => | |
Js.String.split("", input) | |
|> Array.map(int_of_string) | |
|> Array.to_list; | |
let rec solver = (current, next, rest, first, total) => | |
switch (next == first, current == next, rest) { | |
/* when we're on the last item in the list */ | |
| (true, true, []) => total + current + next | |
| (false, true, []) => total + current |