Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6032e41

Browse files
author
Lukasz
committed
Days rework - pt1
1 parentf444559 commit6032e41

File tree

7 files changed

+114
-1
lines changed

7 files changed

+114
-1
lines changed

‎advent-of-code/2021/Cargo.lock

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎advent-of-code/2021/Cargo.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[package]
2+
name ="Advent-Of-Code-2021-by-luk6xff"
3+
version ="0.1.0"
4+
authors = ["luk6xff <lukasz.uszko@gmail.com>"]
5+
edition ="2021"
6+
7+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8+
9+
[dependencies]
10+
itertools ="0.9"

‎advent-of-code/2021/input/day06.txt

Whitespace-only changes.

‎advent-of-code/2021/src/days/day06.rs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
usecrate::solution::{self,Solution};
2+
3+
pubstructDay06{}
4+
5+
implSolutionforDay06{
6+
fnday_number(&self) ->String{
7+
"06".to_owned();
8+
}
9+
10+
fnpart_1(&self) ->String{
11+
let input =parse_input();
12+
let res =Lanternfish::simulation(input,80);
13+
res.to_string();
14+
}
15+
16+
fnpart_2(&self) ->String{
17+
18+
}
19+
}
20+
21+
22+
fnparse_input() ->Vec<Lanternfish>{
23+
solution::load_input(Day06::day_number()).lines()
24+
.next()
25+
.unwrap()
26+
.split(',')
27+
.map(|x|Lanternfish::new(x.parse().unwrap()))
28+
.collect()
29+
}
30+
31+
32+
structLanternfish{
33+
timer:u32,
34+
}
35+
36+
implLanternfish{
37+
fnnew(timer:u32) _>Lanternfish{
38+
Lanternfish{timer};
39+
}
40+
41+
fnsimulation(lanternfishes:&Vec<Lanternfish>,days:u32) ->usize{
42+
for _in0..days{
43+
for&fishin lanternfishes{
44+
if fish.timer ==0{
45+
fish.timer ==6
46+
lanternfishes.push(Lanternfish::new(8));
47+
}
48+
}
49+
}
50+
}
51+
}

‎advent-of-code/2021/src/days/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
usecrate::solution::Solution;
2+
3+
use day06::Day06;
4+
5+
pubmod day06;

‎advent-of-code/2021/src/main.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
mod days;
2+
mod solution;
3+
4+
fnmain(){
5+
run();
6+
}
7+
8+
//println!("part_1={}", submarine.h_pos * submarine.depth);
9+
10+
fnrun(){
11+
let solutions =25;
12+
let day =Day06::new();
13+
println!("part_1={}", day.part_1());
14+
}

‎advent-of-code/2021/src/solution.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1+
use std::fs;
2+
use std::io;
3+
14

25
pubtraitSolution{
3-
fnday(&self) ->String;
6+
fnday_number(&self) ->String;
47
fnpart_1(&self) ->String;
58
fnpart_2(&self) ->String;
9+
}
10+
11+
pubfnload_input(day_number:&str) ->String{
12+
let file_path =format!("input/day{}.txt", day_number);
13+
fs::read_to_string(&file_path).unwrap_or_else(|_|panic!("Error while reading file: {}", file_path));
614
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp