3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
/target
|
||||||
|
*~
|
||||||
|
\#*#
|
5
README.org
Normal file
5
README.org
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
Personal repo for practicing random stuff from Project Euler and try to learn haskell after my similar last attempt over an year ago
|
||||||
|
|
||||||
|
- Do not cheat
|
||||||
|
- My solutions suck anyway (probably)
|
||||||
|
- They need not be the best
|
1
haskell/Lib.hs
Normal file
1
haskell/Lib.hs
Normal file
@@ -0,0 +1 @@
|
|||||||
|
module Lib where
|
8
haskell/README.org
Normal file
8
haskell/README.org
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
* Compile
|
||||||
|
Just run =ghc p<x>.hs= where <x> is the problem number
|
||||||
|
|
||||||
|
* Run
|
||||||
|
Just run =runhaskell p<x>.hs= where <x> is the problem number
|
||||||
|
|
||||||
|
* Environment
|
||||||
|
If you use nix just run =nix develop= or =nix develop .#withLsp= if you want haskell-language-server.
|
43
haskell/flake.lock
generated
Normal file
43
haskell/flake.lock
generated
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1666610816,
|
||||||
|
"narHash": "sha256-q4F2VNe5bpxXOvp16DyLwE1SgNZMbNO29ZQJPIomedg=",
|
||||||
|
"owner": "nixos",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "6107f97012a0c134c5848125b5aa1b149b76d2c9",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nixos",
|
||||||
|
"ref": "release-22.05",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": "nixpkgs",
|
||||||
|
"utils": "utils"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"utils": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1659877975,
|
||||||
|
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
31
haskell/flake.nix
Normal file
31
haskell/flake.nix
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
description = "eulerfunt in haskell";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = github:nixos/nixpkgs/release-22.05;
|
||||||
|
utils.url = github:numtide/flake-utils;
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = { self, nixpkgs, utils }:
|
||||||
|
utils.lib.eachDefaultSystem
|
||||||
|
(system:
|
||||||
|
let
|
||||||
|
pkgs = import nixpkgs {
|
||||||
|
inherit system;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
devShells = with pkgs; rec {
|
||||||
|
default = mkShell {
|
||||||
|
buildInputs = [ ghc ];
|
||||||
|
};
|
||||||
|
withLsp = mkShell {
|
||||||
|
buildInputs = [
|
||||||
|
ghc
|
||||||
|
haskell-language-server
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
2
rust/.gitignore
vendored
Normal file
2
rust/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
/target
|
||||||
|
*~
|
7
rust/Cargo.lock
generated
Normal file
7
rust/Cargo.lock
generated
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
version = 3
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "eulerfunt"
|
||||||
|
version = "0.1.0"
|
4
rust/Cargo.toml
Normal file
4
rust/Cargo.toml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
[package]
|
||||||
|
name = "eulerfunt"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
5
rust/README.org
Normal file
5
rust/README.org
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
* Run
|
||||||
|
Just run =cargo run --bin p<x>= where <x> is the problem number
|
||||||
|
|
||||||
|
* Environment
|
||||||
|
If you use nix just run =nix develop= or =nix develop .#withLsp= if you want rust-analyzer.
|
94
rust/flake.lock
generated
Normal file
94
rust/flake.lock
generated
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"flake-utils": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1659877975,
|
||||||
|
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1666610816,
|
||||||
|
"narHash": "sha256-q4F2VNe5bpxXOvp16DyLwE1SgNZMbNO29ZQJPIomedg=",
|
||||||
|
"owner": "nixos",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "6107f97012a0c134c5848125b5aa1b149b76d2c9",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nixos",
|
||||||
|
"ref": "release-22.05",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs_2": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1665296151,
|
||||||
|
"narHash": "sha256-uOB0oxqxN9K7XGF1hcnY+PQnlQJ+3bP2vCn/+Ru/bbc=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "14ccaaedd95a488dd7ae142757884d8e125b3363",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixpkgs-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": "nixpkgs",
|
||||||
|
"rust-overlay": "rust-overlay",
|
||||||
|
"utils": "utils"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"rust-overlay": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-utils": "flake-utils",
|
||||||
|
"nixpkgs": "nixpkgs_2"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1666752703,
|
||||||
|
"narHash": "sha256-8l/yUNj3eH89T5uPDOZKjYNeOTSmn8xJCRC0c/Jedl8=",
|
||||||
|
"owner": "oxalica",
|
||||||
|
"repo": "rust-overlay",
|
||||||
|
"rev": "b20d7b01b37268f240d185f5a2902d5fecb48ad3",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "oxalica",
|
||||||
|
"repo": "rust-overlay",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"utils": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1659877975,
|
||||||
|
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
36
rust/flake.nix
Normal file
36
rust/flake.nix
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
description = "eulerfunt in Rust";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = github:nixos/nixpkgs/release-22.05;
|
||||||
|
utils.url = github:numtide/flake-utils;
|
||||||
|
rust-overlay.url = github:oxalica/rust-overlay;
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = { self, nixpkgs, utils, rust-overlay }:
|
||||||
|
utils.lib.eachDefaultSystem
|
||||||
|
(system:
|
||||||
|
let
|
||||||
|
overlays = [ rust-overlay.overlays.default ];
|
||||||
|
|
||||||
|
pkgs = import nixpkgs {
|
||||||
|
inherit system overlays;
|
||||||
|
};
|
||||||
|
|
||||||
|
toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
devShells = rec {
|
||||||
|
default = pkgs.mkShell {
|
||||||
|
buildInputs = [ toolchain ];
|
||||||
|
};
|
||||||
|
withLsp = pkgs.mkShell {
|
||||||
|
buildInputs = [
|
||||||
|
toolchain
|
||||||
|
pkgs.rust-analyzer
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
26
rust/gentoml
Executable file
26
rust/gentoml
Executable file
@@ -0,0 +1,26 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
toml=Cargo.toml
|
||||||
|
name=eulerfunt
|
||||||
|
|
||||||
|
cat > $toml <<EOF
|
||||||
|
[package]
|
||||||
|
name = "$name"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
EOF
|
||||||
|
|
||||||
|
if ! [ -e ./src/p*.rs ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
for problem in ./src/p*.rs; do
|
||||||
|
file=${problem##*/}
|
||||||
|
bin=${file%.*}
|
||||||
|
cat >> $toml <<EOF
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "$bin"
|
||||||
|
path = "$problem"
|
||||||
|
EOF
|
||||||
|
done
|
3
rust/rust-toolchain
Normal file
3
rust/rust-toolchain
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
[toolchain]
|
||||||
|
channel = "nightly-2022-10-26"
|
||||||
|
components = [ "rustfmt", "clippy" ]
|
0
rust/src/lib.rs
Normal file
0
rust/src/lib.rs
Normal file
Reference in New Issue
Block a user