Reordering and changing code
This commit is contained in:
parent
2c055a1094
commit
f52ee7b545
|
@ -3,7 +3,7 @@
|
|||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "day1"
|
||||
name = "day01"
|
||||
version = "0.1.0"
|
||||
|
||||
[[package]]
|
||||
|
|
26
Cargo.toml
26
Cargo.toml
|
@ -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",
|
||||
]
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "day1"
|
||||
name = "day01"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
|
@ -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
|
Loading…
Reference in New Issue