diff options
Diffstat (limited to 'util')
-rwxr-xr-x | util/get | 17 | ||||
-rw-r--r-- | util/main.nim | 16 | ||||
-rw-r--r-- | util/main.rs | 8 | ||||
-rwxr-xr-x | util/one | 7 | ||||
-rwxr-xr-x | util/run | 5 | ||||
-rwxr-xr-x | util/two | 7 | ||||
-rwxr-xr-x | util/watch | 7 |
7 files changed, 67 insertions, 0 deletions
diff --git a/util/get b/util/get new file mode 100755 index 0000000..423dfca --- /dev/null +++ b/util/get @@ -0,0 +1,17 @@ +#!/bin/bash + +source "vars" +INPUT_URL="https://adventofcode.com/${YEAR}/day/$((10#${DAY}))/input" + +mkdir "nim/day${DAY}" +mkdir "nim/day${DAY}/src" +cp "main.nim" "nim/day${DAY}/src/main.nim" +curl $INPUT_URL --cookie "session=${TOKEN}" > "nim/day${DAY}/input.txt" + +cargo new "rust/day${DAY}" +cp "main.rs" "rust/day${DAY}/src/main.rs" +cp "nim/day${DAY}/input.txt" "rust/day${DAY}/input.txt" + +subl -a "nim/day${DAY}/input.txt" +subl -a "nim/day${DAY}/src/main.nim" +# chromium "https://adventofcode.com/${YEAR}/day/$((10#${DAY}))" diff --git a/util/main.nim b/util/main.nim new file mode 100644 index 0000000..15ba6b9 --- /dev/null +++ b/util/main.nim @@ -0,0 +1,16 @@ +# Day ???: ??? +import std/[os, strutils, sequtils, sugar] +# import std/[algorithm, math, hashes, tables, sets] +# import std/[strformat, strscans, enumerate] + +# useful functions and things to remember: +# - readFile, splitLines, split(""), strip({''}) +# - map(func), filter(func), all(func), any(func) +# - foldl(func, init), string.repeat(count), zip(a, b) +# for i, chr in "string": assert "string"[i] == chr +# assert @[0, 1, 2, 3] == collect(for i in 0..3: i) + +let input = paramStr(1).readFile().strip().split("\n") + +for line in input: + discard diff --git a/util/main.rs b/util/main.rs new file mode 100644 index 0000000..2cad662 --- /dev/null +++ b/util/main.rs @@ -0,0 +1,8 @@ +use std::env; +use std::fs; + +fn main() { + let args = env::args().nth(1).expect(""); + let input = fs::read_to_string(args).expect(""); + println!("{}", input); +} diff --git a/util/one b/util/one new file mode 100755 index 0000000..6b7db35 --- /dev/null +++ b/util/one @@ -0,0 +1,7 @@ +#!/bin/bash + +source "vars" +LEVEL="1" +SUBMIT_URL="https://adventofcode.com/${YEAR}/day/$((10#${DAY}))/answer" + +curl $SUBMIT_URL --cookie "session=${TOKEN}" --data "level=${LEVEL}&answer=$1" | rg -C 1 "main" diff --git a/util/run b/util/run new file mode 100755 index 0000000..3d068e1 --- /dev/null +++ b/util/run @@ -0,0 +1,5 @@ +#!/bin/bash + +source "vars" + +nim c --warnings:off --hints:off -r "nim/day${DAY}/src/main.nim" "nim/day${DAY}/input.txt" diff --git a/util/two b/util/two new file mode 100755 index 0000000..8dd0080 --- /dev/null +++ b/util/two @@ -0,0 +1,7 @@ +#!/bin/bash + +source "vars" +LEVEL="2" +SUBMIT_URL="https://adventofcode.com/${YEAR}/day/$((10#${DAY}))/answer" + +curl $SUBMIT_URL --cookie "session=${TOKEN}" --data "level=${LEVEL}&answer=$1" | rg -C 1 "main" diff --git a/util/watch b/util/watch new file mode 100755 index 0000000..9c79c6e --- /dev/null +++ b/util/watch @@ -0,0 +1,7 @@ +#!/bin/bash + +source "vars" + +while inotifywait --quiet --event modify "nim/day${DAY}/src/main.nim" +do ./run +done |