Reordering and changing code

This commit is contained in:
Bizcochito 2022-12-01 16:33:24 +01:00
parent 2c055a1094
commit f52ee7b545
5 changed files with 30 additions and 7 deletions

2
Cargo.lock generated
View File

@ -3,7 +3,7 @@
version = 3
[[package]]
name = "day1"
name = "day01"
version = "0.1.0"
[[package]]

View File

@ -2,5 +2,29 @@
members = [
"tiesto",
"day1",
"day01",
"day02",
"day03",
"day04",
"day05",
"day06",
"day07",
"day08",
"day09",
"day10",
"day11",
"day12",
"day13",
"day14",
"day15",
"day16",
"day17",
"day18",
"day19",
"day20",
"day21",
"day22",
"day23",
"day24",
"day25",
]

View File

@ -1,5 +1,5 @@
[package]
name = "day1"
name = "day01"
version = "0.1.0"
edition = "2021"

View File

@ -17,11 +17,10 @@ fn main() {
fn get_elfs(input: &str) -> Vec<u32> {
let binding = input.to_owned();
let input: Vec<&str> = binding.lines().collect();
let mut elfs = Vec::new();
let mut ptr: usize = 0;
elfs.push(0);
let mut elfs = Vec::from([0]);
for line in input{
if line == "" {ptr+=1; elfs.push(0); continue;}
if line == "" {elfs.push(0); continue;}
let ptr = elfs.len()-1;
elfs[ptr] += u32::from_str(line).expect("all content must be numbers");
}
elfs