From 2dd975ea247c6649c3ef6d63d0e4a5b111eb05e0 Mon Sep 17 00:00:00 2001 From: pegasust Date: Tue, 6 Dec 2022 04:57:59 +0000 Subject: [PATCH] d6 init --- 2022/d6/.envrc | 4 +++ 2022/d6/flake.lock | 43 ++++++++++++++++++++++++++++++++ 2022/d6/flake.nix | 61 ++++++++++++++++++++++++++++++++++++++++++++++ 2022/d6/run-py.sh | 7 ++++++ 2022/d6/src/d6.py | 0 5 files changed, 115 insertions(+) create mode 100644 2022/d6/.envrc create mode 100644 2022/d6/flake.lock create mode 100644 2022/d6/flake.nix create mode 100755 2022/d6/run-py.sh create mode 100644 2022/d6/src/d6.py diff --git a/2022/d6/.envrc b/2022/d6/.envrc new file mode 100644 index 0000000..8ba04f9 --- /dev/null +++ b/2022/d6/.envrc @@ -0,0 +1,4 @@ +if command -v nix-shell &> /dev/null + then + use flake +fi diff --git a/2022/d6/flake.lock b/2022/d6/flake.lock new file mode 100644 index 0000000..a62a638 --- /dev/null +++ b/2022/d6/flake.lock @@ -0,0 +1,43 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1670064435, + "narHash": "sha256-+ELoY30UN+Pl3Yn7RWRPabykwebsVK/kYE9JsIsUMxQ=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "61a8a98e6d557e6dd7ed0cdb54c3a3e3bbc5e25c", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/2022/d6/flake.nix b/2022/d6/flake.nix new file mode 100644 index 0000000..3faf300 --- /dev/null +++ b/2022/d6/flake.nix @@ -0,0 +1,61 @@ +{ + description = "D4 AOC with Lua!"; + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + outputs = { nixpkgs, flake-utils, ... } @ inputs: + flake-utils.lib.eachSystem flake-utils.lib.defaultSystems (sys: + let + overlays = [ ]; + pkgs = import nixpkgs { system = sys; overlays = overlays; }; + shellHookAfter = '' + echo "The input files should be placed under ./data/{submission,example}.txt" + echo "This problem shares one input between two parts" + ''; + py_pkgs = [ pkgs.python310 ]; + # lua_pkgs = [ (pkgs.lua.withPackages (luapkgs: [ luapkgs.busted luapkgs.luafilesystem ])) ]; + fennel_pkgs = [ (pkgs.lua.withPackages (luapkgs: [ luapkgs.fennel luapkgs.readline ])) ]; + in + { + # Jack of all trades + devShell = pkgs.mkShell { + nativeBuildInputs = py_pkgs ++ fennel_pkgs; + shellHook = '' + echo "> Default runtime. This contains both fennel and python3 env" + echo "Run ./run-py.sh for Python's output and ./run-fnl.sh for Fennel's output" + '' + shellHookAfter; + }; + devShells = { + # nix develop ./#lua + # lua = pkgs.mkShell { + # nativeBuildInputs = lua_pkgs; + # shellHook = '' + # echo "> Lua runtime" + # echo "Run ./run-lua.sh to see the output of the solution" + # '' + shellHookAfter; + # }; + + # nix develop ./#fennel + fennel = pkgs.mkShell + { + nativeBuildInputs = fennel_pkgs; + shellHook = '' + echo "> Fennel runtime" + echo "Run ./run-fnl.sh to see output of Fennel solution" + '' + shellHookAfter; + }; + + # nix develop ./#python + python = pkgs.mkShell { + nativeBuildInputs = py_pkgs; + shellHook = '' + echo "> Python3 runtime" + echo "Run ./run-py.sh to see the output of the solution" + '' + shellHookAfter; + + }; + }; + } + ); +} diff --git a/2022/d6/run-py.sh b/2022/d6/run-py.sh new file mode 100755 index 0000000..1fc16f1 --- /dev/null +++ b/2022/d6/run-py.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env sh +echo "example" +python3 ./src/d5.py ./data/example.txt + +echo "submission" +python3 ./src/d5.py ./data/submission.txt + diff --git a/2022/d6/src/d6.py b/2022/d6/src/d6.py new file mode 100644 index 0000000..e69de29