diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore index 3a5d1af..93f695a 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ perf.data perf.data.old flamegraph.svg +.direnv diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..3adcc44 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1783224372, + "narHash": "sha256-8i/87eeoqiGE4yOTjwSA3Eh/ziJRQEmd/unYU+K27sk=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "d407951447dcd00442e97087bf374aad70c04cea", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "utils": "utils" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..4059a9d --- /dev/null +++ b/flake.nix @@ -0,0 +1,25 @@ +{ + inputs = { + utils.url = "github:numtide/flake-utils"; + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + }; + outputs = { self, nixpkgs, utils }: utils.lib.eachDefaultSystem (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + in + { + devShell = pkgs.mkShell { + buildInputs = with pkgs; []; + }; + + packages.default = pkgs.rustPlatform.buildRustPackage (finalAttrs: { + pname = "dynamic-pangramming"; + version = "0.1.0"; + + src = ./.; + + cargoLock.lockFile = ./Cargo.lock; + }); + } + ); +} diff --git a/src/main.rs b/src/main.rs index e6eb34f..b33fc6f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -47,6 +47,7 @@ fn solve(dictionary: &mut [(String, LetterSet)], target: LetterSet) -> Option<(u let mut path = vec![start]; let mut done = LetterSet::from(start); + // this fails sometimes with non-full targets while let (_, Some(word)) = bests[done.to_index()] { path.push(word); done = done.union(LetterSet::from(word));