diff options
-rw-r--r-- | advent-of-code/README.md | 4 | ||||
-rw-r--r-- | advent-of-code/aoc2019.nix | 8 | ||||
-rw-r--r-- | advent-of-code/day_5.ex | 50 | ||||
-rw-r--r-- | advent-of-code/day_5.pyc | bin | 5250 -> 0 bytes | |||
-rw-r--r-- | advent-of-code/writePythonBin.nix | 18 |
5 files changed, 4 insertions, 76 deletions
diff --git a/advent-of-code/README.md b/advent-of-code/README.md new file mode 100644 index 000000000000..e7c105a7f60f --- /dev/null +++ b/advent-of-code/README.md @@ -0,0 +1,4 @@ +# 2019 Advent of Code + +Here are my attempts at the 2019 Advent of Code challenge before my dedication +to the effort plummeted. diff --git a/advent-of-code/aoc2019.nix b/advent-of-code/aoc2019.nix deleted file mode 100644 index 10e6c559a9b4..000000000000 --- a/advent-of-code/aoc2019.nix +++ /dev/null @@ -1,8 +0,0 @@ -with import <nixpkgs> {}; -with python35Packages; - -buildPythonPackage { - name = "wpcarro"; - src = ./day_5.py; - propagatedBuildInputs = [ pytest numpy ]; -} diff --git a/advent-of-code/day_5.ex b/advent-of-code/day_5.ex deleted file mode 100644 index 807e3c9177be..000000000000 --- a/advent-of-code/day_5.ex +++ /dev/null @@ -1,50 +0,0 @@ -defmodule Interpretter do - def interpret_param({mode, x}, xs) do - case mode do - :positional -> Enum.at(xs, x) - :immediate -> x - end - end - - # Perhaps I can model the intepretter after Forth and make it a stack-based - # interpretter with an emphasis on debugability, introspection. - def interpret(i, xs) do - stack = [] - op = Enum.at(xs, i) - - # map instructions into an intermediate representation (i.e. IR) where the - # opcodes are mapped into atoms and the arguments are mapped into references - # or literals. - - instructions = - %{'01' => :add, - '02' => :multiply, - '03' => :input, - '04' => :output, - '05' => :jump_if_true, - '06' => :jump_if_false, - '07' => :less_than, - '08' => :equal_to, - '99' => :return} - - case xs do - [:add, a, b, {:positional, out} | rest] -> - a = interpret_param(a, xs) - b = interpret_param(b, xs) - Interpretter.interpret(i + 3, List.insert_at(xs, out, a + b)) - - [:multiply, a, b, {:positional, out} | rest] -> - a = interpret_param(a, xs) - b = interpret_param(b, xs) - Interpretter.interpret(i + 3, List.insert_at(xs, out, a * b)) - - [:input, a | rest] -> nil - [:output, a | rest] -> nil - [:jump_if_true, a, b | rest] -> nil - [:jump_if_false, a, b | rest] -> nil - [:less_than, a, b, out | rest] -> nil - [:equal_to, a, b, out | rest] -> nil - [:return | _rest] -> nil - end - end -end diff --git a/advent-of-code/day_5.pyc b/advent-of-code/day_5.pyc deleted file mode 100644 index d95573e94326..000000000000 --- a/advent-of-code/day_5.pyc +++ /dev/null Binary files differdiff --git a/advent-of-code/writePythonBin.nix b/advent-of-code/writePythonBin.nix deleted file mode 100644 index 1730edb2ebe4..000000000000 --- a/advent-of-code/writePythonBin.nix +++ /dev/null @@ -1,18 +0,0 @@ -{ pkgs ? import <nixpkgs> {}, ... }: - -{ name, deps, src }: - -let - inherit (pkgs) pythonPackages writeTextFile; - inherit (builtins) toFile; - -in writeTextFile { - inherit name; - executable = true; - destination = "/bin/${name}"; - - text = '' - #!/bin/sh - ${pkgs.python3}/bin/python3 ${src} - ''; -} |