Init Elves.
This commit is contained in:
commit
5c125e7ee7
4 changed files with 47 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
target
|
7
day1/Cargo.lock
generated
Normal file
7
day1/Cargo.lock
generated
Normal 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
11
day1/Cargo.toml
Normal 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
28
day1/src/main.rs
Normal 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()
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue