Skip to content

Commit 7897bdf

Browse files
committed
changed input mechanism
1 parent 97ab970 commit 7897bdf

File tree

73 files changed

+311
-252
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+311
-252
lines changed

src/bin/2015_01/main.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ fn part2(input: &str) -> usize {
2424
}
2525

2626
fn main() {
27-
let input = common::get_input();
28-
common::timed(&input, part1, true);
29-
common::timed(&input, part2, false);
27+
if let Some(input) = common::get_input() {
28+
common::timed(&input, part1, true);
29+
common::timed(&input, part2, false);
30+
}
3031
}

src/bin/2015_02/main.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ fn part2(input: &str) -> i32 {
3030
}
3131

3232
fn main() {
33-
let input = common::get_input();
34-
common::timed(&input, part1, true);
35-
common::timed(&input, part2, false);
33+
if let Some(input) = common::get_input() {
34+
common::timed(&input, part1, true);
35+
common::timed(&input, part2, false);
36+
}
3637
}

src/bin/2020_20/main.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ fn part1(input: &str) -> usize {
9696
}
9797

9898
fn main() {
99-
let input = common::get_input();
100-
common::timed(&input, part1, true);
99+
if let Some(input) = common::get_input() {
100+
common::timed(&input, part1, true);
101+
}
101102
}

src/bin/2022_01/main.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ fn part2(input: &str) -> usize {
3333
}
3434

3535
fn main() {
36-
let input = common::get_input();
37-
common::timed(&input, part1, true);
38-
common::timed(&input, part2, false);
36+
if let Some(input) = common::get_input() {
37+
common::timed(&input, part1, true);
38+
common::timed(&input, part2, false);
39+
}
3940
}

src/bin/2022_02/main.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ fn part2(input_lines: &str) -> i32 {
4343
}
4444

4545
fn main() {
46-
let input = common::get_input();
47-
common::timed(&input, part1, true);
48-
common::timed(&input, part2, false);
46+
if let Some(input) = common::get_input() {
47+
common::timed(&input, part1, true);
48+
common::timed(&input, part2, false);
49+
}
4950
}

src/bin/2022_03/main.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ fn part2(input: &str) -> usize {
4747
}
4848

4949
fn main() {
50-
let input = common::get_input();
51-
common::timed(&input, part1, true);
52-
common::timed(&input, part2, false);
50+
if let Some(input) = common::get_input() {
51+
common::timed(&input, part1, true);
52+
common::timed(&input, part2, false);
53+
}
5354
}

src/bin/2022_04/main.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ fn part2(input_lines: &str) -> usize {
3737
}
3838

3939
fn main() {
40-
let input = common::get_input();
41-
common::timed(&input, part1, true);
42-
common::timed(&input, part2, false);
40+
if let Some(input) = common::get_input() {
41+
common::timed(&input, part1, true);
42+
common::timed(&input, part2, false);
43+
}
4344
}

src/bin/2022_05/main.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ fn process_and_solve<const PART1: bool>(input: &str) -> String {
8080
}
8181

8282
fn main() {
83-
let input = common::get_input();
84-
common::timed(&input, process_and_solve::<true>, true);
85-
common::timed(&input, process_and_solve::<false>, false);
83+
if let Some(input) = common::get_input() {
84+
common::timed(&input, process_and_solve::<true>, true);
85+
common::timed(&input, process_and_solve::<false>, false);
86+
}
8687
}

src/bin/2022_06/main.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ fn part2(input: &str) -> usize {
2828
}
2929

3030
fn main() {
31-
let input = common::get_input();
32-
common::timed(&input, part1, true);
33-
common::timed(&input, part2, false);
31+
if let Some(input) = common::get_input() {
32+
common::timed(&input, part1, true);
33+
common::timed(&input, part2, false);
34+
}
3435
}

src/bin/2022_07/main.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ fn part2(dir_size_map: &HashMap<String, usize>) -> usize {
8989
}
9090

9191
fn main() {
92-
let input = common::get_input();
93-
common::timed(&input, process_and_solve::<true>, true);
94-
common::timed(&input, process_and_solve::<false>, false);
92+
if let Some(input) = common::get_input() {
93+
common::timed(&input, process_and_solve::<true>, true);
94+
common::timed(&input, process_and_solve::<false>, false);
95+
}
9596
}

0 commit comments

Comments
 (0)