chore: formatting and cleanup
This commit is contained in:
parent
c0acf9524a
commit
43a25ed66f
4 changed files with 50 additions and 27 deletions
36
.gitignore
vendored
36
.gitignore
vendored
|
@ -13,3 +13,39 @@ devenv.local.nix
|
|||
|
||||
/target
|
||||
/**/*.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
|
||||
|
|
26
devenv.lock
26
devenv.lock
|
@ -3,10 +3,10 @@
|
|||
"devenv": {
|
||||
"locked": {
|
||||
"dir": "src/modules",
|
||||
"lastModified": 1733788855,
|
||||
"lastModified": 1737028622,
|
||||
"owner": "cachix",
|
||||
"repo": "devenv",
|
||||
"rev": "d59fee8696cd48f69cf79f65992269df9891ba86",
|
||||
"rev": "4e5b00134bf03f16af6b25b80abb38c598cfe239",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -66,35 +66,19 @@
|
|||
"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": {
|
||||
"inputs": {
|
||||
"flake-compat": "flake-compat",
|
||||
"gitignore": "gitignore",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
],
|
||||
"nixpkgs-stable": "nixpkgs-stable"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1733665616,
|
||||
"lastModified": 1737043064,
|
||||
"owner": "cachix",
|
||||
"repo": "pre-commit-hooks.nix",
|
||||
"rev": "d8c02f0ffef0ef39f6063731fc539d8c71eb463a",
|
||||
"rev": "94ee657f6032d913fe0ef49adaa743804635b0bb",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
|
@ -25,10 +25,7 @@
|
|||
hello
|
||||
git --version
|
||||
'';
|
||||
|
||||
languages = {
|
||||
rust.enable = true;
|
||||
};
|
||||
languages.rust.enable = true;
|
||||
# https://devenv.sh/tasks/
|
||||
# tasks = {
|
||||
# "myproj:setup".exec = "mytool build";
|
||||
|
|
10
src/day3.rs
10
src/day3.rs
|
@ -1,6 +1,8 @@
|
|||
use std::fs;
|
||||
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_num = &first_part[4..];
|
||||
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 trim_str = tmp.split_at(end_index + 1).0;
|
||||
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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue