1
0
Fork 0

Init Elves.

This commit is contained in:
Yohan Boujon 2023-10-10 15:01:13 +02:00
commit 5c125e7ee7
4 changed files with 47 additions and 0 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
target

7
day1/Cargo.lock generated Normal file
View file

@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "aoc-day1"
version = "0.1.0"

11
day1/Cargo.toml Normal file
View file

@ -0,0 +1,11 @@
[package]
name = "aoc-day1"
version = "0.1.0"
edition = "2021"
authors = ["Yohan Boujon <yoboujon@gmail.com>"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
[workspace]

28
day1/src/main.rs Normal file
View file

@ -0,0 +1,28 @@
pub struct Elf {
inventory : Vec<u64>,
}
impl Elf {
pub fn new(vec : Vec<u64>) -> Elf {
Elf {
inventory: vec,
}
}
pub fn print_inventory(& self)
{
for inv in &self.inventory {
println!("{}",inv)
}
}
}
fn main()
{
let elves = vec![Elf::new(vec![1000,2000,3000]),Elf::new(vec![4000]), Elf::new(vec![5000,6000]), Elf::new(vec![7000,8000,9000]), Elf::new(vec![10000])];
for elf in &elves
{
println!("Elf :");
elf.print_inventory()
}
}