From 479648eea0aa390b8248491280e571d46d64e9e3 Mon Sep 17 00:00:00 2001 From: newt Date: Wed, 9 Oct 2024 18:10:10 +0100 Subject: [PATCH] chore(build): create build script --- .gitignore | 2 +- .vscode/settings.json | 13 +++++++++++++ Cargo.toml | 8 ++++++-- build.sh | 14 ++++++++++++++ readme.md | 6 +++++- src/bin/15.rs | 1 - 6 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 .vscode/settings.json create mode 100755 build.sh diff --git a/.gitignore b/.gitignore index a0f8b31..e868f39 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ /target -/ignore +/binaries diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..c698016 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,13 @@ +{ + "files.exclude": { + "**/.git": true, + "**/.svn": true, + "**/.hg": true, + "**/CVS": true, + "**/.DS_Store": true, + "**/Thumbs.db": true, + "**/target": true, + "**/Cargo.lock": true, + "**/euler.png": true + } +} diff --git a/Cargo.toml b/Cargo.toml index 3719129..c2f1f49 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,8 +4,6 @@ version = "1.0.0" edition = "2021" default-run = "euler" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] clap = { version = "4.0.4", features = ["derive"] } owo-colors = "3.5.0" @@ -15,3 +13,9 @@ reqwest = "0.11" tokio = { version = "1.23", features = ["full"] } regex = "1" html-escape = "0.2.13" + +[profile.release] +opt-level = "z" +strip = true +lto = true +codegen-units = 1 diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..e0d2f39 --- /dev/null +++ b/build.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +cargo build --release --bin "[0-9]*" -q +cargo build --release --bin "[0-9]*" -q --target x86_64-pc-windows-gnu + +find ./target/release -maxdepth 1 -type f -perm 755 | while read file; do + arr=(${file//\// }) + mv $file binaries/linux/${arr[3]} +done + +find ./target/x86_64-pc-windows-gnu/release -maxdepth 1 -type f -perm 755 | while read file; do + arr=(${file//\// }) + mv $file binaries/win64/${arr[4]} +done diff --git a/readme.md b/readme.md index dc4b834..5178bd0 100644 --- a/readme.md +++ b/readme.md @@ -7,6 +7,8 @@ All of the solutions here are written in rust. [main.rs](src/main.rs) is the home to my helper command line that can scaffold files for me quickly, prefaced with a statement of the problem! As per the rules of the challenge, I may only publish the solutions to the first 100 problems here, so I will stop after that but still continue the challenge. +I originally started the challenge in [the-honk](https://github.com/newtykins/the-honk) in TypeScript, and am currently in the process of porting over all of my already completed challenges. Check out my old work [here](https://github.com/newtykins/the-honk/tree/main/challenges/euler). + ## Challenge Completion ### 15 out of 100 public challenges completed. @@ -110,4 +112,6 @@ All of the solutions here are written in rust. [main.rs](src/main.rs) is the hom - [ ] 97 - Large non-Mersenne prime - [ ] 98 - Anagramic squares - [ ] 99 - Largest exponential -- [ ] 100 - Arranged probability \ No newline at end of file +- [ ] 100 - Arranged probability + +Check out Project Euler here. diff --git a/src/bin/15.rs b/src/bin/15.rs index b005fe1..7e76e4d 100644 --- a/src/bin/15.rs +++ b/src/bin/15.rs @@ -23,7 +23,6 @@ fn count_lattice_paths(width: usize, height: usize) -> usize { if width != height { return binomial(width + height, width).unwrap(); } - // (2n, n) else { let mut result: usize = 1;