chore: formatting and cleanup

This commit is contained in:
Zhongheng Liu 2025-01-18 14:14:12 +02:00
commit 43a25ed66f
Signed by: steven
GPG key ID: 805A28B071DAD84B
4 changed files with 50 additions and 27 deletions

36
.gitignore vendored
View file

@ -13,3 +13,39 @@ devenv.local.nix
/target /target
/**/*.input /**/*.input
# Devenv
.devenv*
devenv.local.nix
# direnv
.direnv
# pre-commit
.pre-commit-config.yaml
# Devenv
.devenv*
devenv.local.nix
# direnv
.direnv
# pre-commit
.pre-commit-config.yaml
# Devenv
.devenv*
devenv.local.nix
# direnv
.direnv
# pre-commit
.pre-commit-config.yaml
# Devenv
.devenv*
devenv.local.nix
# direnv
.direnv
# pre-commit
.pre-commit-config.yaml

View file

@ -3,10 +3,10 @@
"devenv": { "devenv": {
"locked": { "locked": {
"dir": "src/modules", "dir": "src/modules",
"lastModified": 1733788855, "lastModified": 1737028622,
"owner": "cachix", "owner": "cachix",
"repo": "devenv", "repo": "devenv",
"rev": "d59fee8696cd48f69cf79f65992269df9891ba86", "rev": "4e5b00134bf03f16af6b25b80abb38c598cfe239",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -66,35 +66,19 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs-stable": {
"locked": {
"lastModified": 1733730953,
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "7109b680d161993918b0a126f38bc39763e5a709",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-24.05",
"repo": "nixpkgs",
"type": "github"
}
},
"pre-commit-hooks": { "pre-commit-hooks": {
"inputs": { "inputs": {
"flake-compat": "flake-compat", "flake-compat": "flake-compat",
"gitignore": "gitignore", "gitignore": "gitignore",
"nixpkgs": [ "nixpkgs": [
"nixpkgs" "nixpkgs"
], ]
"nixpkgs-stable": "nixpkgs-stable"
}, },
"locked": { "locked": {
"lastModified": 1733665616, "lastModified": 1737043064,
"owner": "cachix", "owner": "cachix",
"repo": "pre-commit-hooks.nix", "repo": "pre-commit-hooks.nix",
"rev": "d8c02f0ffef0ef39f6063731fc539d8c71eb463a", "rev": "94ee657f6032d913fe0ef49adaa743804635b0bb",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -25,10 +25,7 @@
hello hello
git --version git --version
''; '';
languages.rust.enable = true;
languages = {
rust.enable = true;
};
# https://devenv.sh/tasks/ # https://devenv.sh/tasks/
# tasks = { # tasks = {
# "myproj:setup".exec = "mytool build"; # "myproj:setup".exec = "mytool build";

View file

@ -1,6 +1,8 @@
use std::fs; use std::fs;
fn check_mul(instruction: &str) -> bool { fn check_mul(instruction: &str) -> bool {
if instruction.find(',').is_none() { return false; } if instruction.find(',').is_none() {
return false;
}
let (first_part, second_part) = instruction.split_once(',').expect("Expected mul to split"); let (first_part, second_part) = instruction.split_once(',').expect("Expected mul to split");
let first_num = &first_part[4..]; let first_num = &first_part[4..];
let second_num = &second_part[..second_part.len() - 1]; let second_num = &second_part[..second_part.len() - 1];
@ -32,7 +34,11 @@ pub fn part1(input_file_path: &str) {
let end_index = tmp.find(')').expect("expected a closure"); let end_index = tmp.find(')').expect("expected a closure");
let trim_str = tmp.split_at(end_index + 1).0; let trim_str = tmp.split_at(end_index + 1).0;
println!("{}", trim_str); println!("{}", trim_str);
total += if check_mul(trim_str) {eval_mul(trim_str)} else {0}; total += if check_mul(trim_str) {
eval_mul(trim_str)
} else {
0
};
}); });
println!("Eval result: {}", total); println!("Eval result: {}", total);
} }