-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
84 additions
and
83 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[package] | ||
name = "day_1_rust" | ||
name = "rust_2022_01" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[package] | ||
name = "day_2_rust" | ||
name = "rust_2022_02" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
|
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[package] | ||
name = "day_3_rust" | ||
name = "rust_2022_03" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
|
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[package] | ||
name = "day_4_rust" | ||
name = "rust_2022_04" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
|
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[package] | ||
name = "rust_2022_05" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
mod crates_iter; | ||
mod procedure; | ||
mod supply_stacks; | ||
|
||
use procedure::Procuedure; | ||
use supply_stacks::SupplyStacks; | ||
|
||
fn main() { | ||
let data = include_str!("../../input.txt"); | ||
|
||
let (string_stacks, procedures_str) = data.split_once("\n\n").unwrap(); | ||
|
||
let mut stacks = SupplyStacks::new(string_stacks); | ||
|
||
let procedures = procedures_str | ||
.lines() | ||
.map(|line| Procuedure::from(line)) | ||
.collect::<Vec<Procuedure>>(); | ||
|
||
for proc in procedures { | ||
stacks.apply_procedure(&proc, false); | ||
} | ||
|
||
let highest_vec = stacks.get_highest_elements(); | ||
let highest_str = highest_vec.iter().collect::<String>(); | ||
|
||
println!("{highest_str}"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#[derive(Debug)] | ||
pub struct Procuedure { | ||
pub move_from: usize, | ||
pub move_to: usize, | ||
pub crates_count: u32, | ||
} | ||
|
||
impl From<&str> for Procuedure { | ||
fn from(string: &str) -> Self { | ||
let items = string.split(" ").collect::<Vec<&str>>(); | ||
|
||
return Procuedure { | ||
crates_count: items[1].parse::<u32>().unwrap(), | ||
move_from: items[3].parse::<usize>().unwrap(), | ||
move_to: items[5].parse::<usize>().unwrap(), | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
[workspace] | ||
resolver = "2" | ||
members = [ | ||
"day_1/rust", | ||
"day_2/rust", | ||
"day_3/rust", | ||
"day_4/rust", | ||
"day_5/rust" | ||
] | ||
"2022/day_1/rust", | ||
"2022/day_2/rust", | ||
"2022/day_3/rust", | ||
"2022/day_4/rust", | ||
"2022/day_5/rust" | ||
] | ||
exclude = [ "2022" ] |
This file was deleted.
Oops, something went wrong.