We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d6c0d1a commit a46140bCopy full SHA for a46140b
src/day01.rs
@@ -1,10 +1,8 @@
1
use std::collections::HashMap;
2
use std::fs;
3
use std::iter::zip;
4
-use std::path::PathBuf;
5
6
-pub fn day01(mut input_path: PathBuf) {
7
- input_path.push("01.txt");
+pub fn day01(input_path: String) {
8
let input: String = fs::read_to_string(input_path).unwrap();
9
let (mut left, mut right) = parse_input(&input);
10
src/day02.rs
use std::hash::Hash;
-pub fn day02(mut input_path: PathBuf) {
- input_path.push("02.txt");
+pub fn day02(input_path: String) {
let content = fs::read_to_string(input_path).unwrap();
let input = parse_input(&content);
src/day03.rs
@@ -1,8 +1,6 @@
-pub fn day03(mut input_path: PathBuf) {
- input_path.push("03.txt");
+pub fn day03(input_path: String) {
println!(
src/day04.rs
-pub fn day04(mut input_path: PathBuf) {
- input_path.push("04.txt");
+pub fn day04(input_path: String) {
let input = fs::read_to_string(input_path).unwrap();
let data = parse_input(&input);
src/day05.rs
@@ -1,11 +1,9 @@
use std::collections::{HashMap, HashSet};
use itertools::Itertools;
-pub fn day05(mut input_path: PathBuf) {
- input_path.push("05.txt");
+pub fn day05(input_path: String) {
11
let (rules, pages_list) = parse_input(&input);
src/day06.rs
@@ -11,11 +11,9 @@ use std::collections::BTreeMap;
12
use std::collections::HashSet;
13
14
15
use tailcall::tailcall;
16
17
-pub fn day06(mut input_path: PathBuf) {
18
- input_path.push("06.txt");
+pub fn day06(input_path: String) {
19
20
21
let (field, guard) = read(&content);
src/day07.rs
@@ -1,10 +1,9 @@
-use std::{fs, iter::zip, num::ParseIntError, path::PathBuf, str::FromStr};
+use std::{fs, iter::zip, num::ParseIntError, str::FromStr};
use rayon::prelude::*;
-pub fn day07(mut input_path: PathBuf) {
- input_path.push("07.txt");
+pub fn day07(input_path: String) {
let equations: Vec<Equation> = content.lines().map(|l| l.parse().unwrap()).collect();
src/day08.rs
@@ -2,13 +2,11 @@ use std::{
cmp,
collections::{HashMap, HashSet},
fs,
- path::PathBuf,
};
use itertools::iproduct;
-pub fn day08(mut input_path: PathBuf) {
- input_path.push("08.txt");
+pub fn day08(input_path: String) {
let (antennas, corner) = read(&content);
src/main.rs
@@ -1,7 +1,6 @@
#![feature(cmp_minmax)]
use clap::Parser;
mod day01;
mod day02;
@@ -16,19 +15,21 @@ mod day08;
struct Args {
#[arg(short, long, default_value_t = 0)]
day: u8,
+
+ #[arg(short, long, default_value = "input")]
+ input_path: String,
}
22
23
fn main() {
24
let args = Args::parse();
- let input = PathBuf::from("input");
25
match args.day {
- 1 => day01::day01(input),
26
- 2 => day02::day02(input),
27
- 3 => day03::day03(input),
28
- 4 => day04::day04(input),
29
- 5 => day05::day05(input),
30
- 6 => day06::day06(input),
31
- 7 => day07::day07(input),
32
- _ => day08::day08(input),
+ 1 => day01::day01(args.input_path),
+ 2 => day02::day02(args.input_path),
+ 3 => day03::day03(args.input_path),
+ 4 => day04::day04(args.input_path),
+ 5 => day05::day05(args.input_path),
+ 6 => day06::day06(args.input_path),
+ 7 => day07::day07(args.input_path),
33
+ _ => day08::day08(args.input_path),
34
35
0 commit comments