fix input path

This commit is contained in:
gbrochar 2022-12-16 15:30:18 +01:00
parent e0b3908019
commit 737c255cc6
10 changed files with 34 additions and 34 deletions

View File

@ -3,11 +3,11 @@ use std::io::{self, BufRead};
use std::path::Path; use std::path::Path;
fn main() { fn main() {
let file_path = String::from("/home/wafoo/advent_of_code_2022/aoc_01/input"); let file_path = String::from("input");
let mut result_vec = Vec::<u32>::new(); let mut result_vec = Vec::<u32>::new();
result_vec.push(0); result_vec.push(0);
println!("In file {}", file_path); println!("In file {}", file_path);
if let Ok(lines) = read_lines(file_path) { if let Ok(lines) = read_lines(file_path) {
@ -22,7 +22,7 @@ fn main() {
} }
} }
} }
} }
} }
let index = result_vec.len() - 1; let index = result_vec.len() - 1;
@ -35,4 +35,4 @@ fn read_lines<P>(filename: P) -> io::Result<io::Lines<io::BufReader<File>>>
where P: AsRef<Path>, { where P: AsRef<Path>, {
let file = File::open(filename)?; let file = File::open(filename)?;
Ok(io::BufReader::new(file).lines()) Ok(io::BufReader::new(file).lines())
} }

View File

@ -3,9 +3,9 @@ use std::io::{self, BufRead};
use std::path::Path; use std::path::Path;
fn main() { fn main() {
let file_path = String::from("/home/wafoo/advent_of_code_2022/aoc_02/input"); let file_path = String::from("input");
let mut result = 0; let mut result = 0;
println!("In file {}", file_path); println!("In file {}", file_path);
if let Ok(lines) = read_lines(file_path) { if let Ok(lines) = read_lines(file_path) {
@ -25,7 +25,7 @@ fn main() {
_ => result += 0, _ => result += 0,
} }
} }
} }
} }
println!("{}", result); println!("{}", result);
@ -35,4 +35,4 @@ fn read_lines<P>(filename: P) -> io::Result<io::Lines<io::BufReader<File>>>
where P: AsRef<Path>, { where P: AsRef<Path>, {
let file = File::open(filename)?; let file = File::open(filename)?;
Ok(io::BufReader::new(file).lines()) Ok(io::BufReader::new(file).lines())
} }

View File

@ -4,9 +4,9 @@ use std::path::Path;
use std::collections::HashMap; use std::collections::HashMap;
fn main() { fn main() {
let file_path = String::from("/home/wafoo/advent_of_code_2022/aoc_03a/input"); let file_path = String::from("input");
let mut result = 0; let mut result = 0;
println!("In file {}", file_path); println!("In file {}", file_path);
if let Ok(lines) = read_lines(file_path) { if let Ok(lines) = read_lines(file_path) {
@ -37,7 +37,7 @@ fn main() {
i += 1; i += 1;
} }
} }
} }
} }
println!("{}", result); println!("{}", result);
@ -47,4 +47,4 @@ fn read_lines<P>(filename: P) -> io::Result<io::Lines<io::BufReader<File>>>
where P: AsRef<Path>, { where P: AsRef<Path>, {
let file = File::open(filename)?; let file = File::open(filename)?;
Ok(io::BufReader::new(file).lines()) Ok(io::BufReader::new(file).lines())
} }

View File

@ -4,7 +4,7 @@ use std::path::Path;
use std::collections::HashMap; use std::collections::HashMap;
fn main() { fn main() {
let file_path = String::from("/home/wafoo/advent_of_code_2022/aoc_03a/input"); let file_path = String::from("../aoc_03a/input");
let mut result = 0; let mut result = 0;
let mut i = 0; let mut i = 0;
let mut hashmap = HashMap::new(); let mut hashmap = HashMap::new();
@ -46,7 +46,7 @@ fn main() {
} }
} }
i = (i + 1) % 3; i = (i + 1) % 3;
} }
} }
println!("{}", result); println!("{}", result);
@ -56,4 +56,4 @@ fn read_lines<P>(filename: P) -> io::Result<io::Lines<io::BufReader<File>>>
where P: AsRef<Path>, { where P: AsRef<Path>, {
let file = File::open(filename)?; let file = File::open(filename)?;
Ok(io::BufReader::new(file).lines()) Ok(io::BufReader::new(file).lines())
} }

View File

@ -3,7 +3,7 @@ use std::io::{self, BufRead};
use std::path::Path; use std::path::Path;
fn main() { fn main() {
let file_path = String::from("/home/wafoo/advent_of_code_2022/aoc_04a/input"); let file_path = String::from("input");
let mut result = 0; let mut result = 0;
println!("In file {}", file_path); println!("In file {}", file_path);
@ -24,7 +24,7 @@ fn main() {
result += 1; result += 1;
} }
} }
} }
} }
println!("{}", result); println!("{}", result);
@ -34,4 +34,4 @@ fn read_lines<P>(filename: P) -> io::Result<io::Lines<io::BufReader<File>>>
where P: AsRef<Path>, { where P: AsRef<Path>, {
let file = File::open(filename)?; let file = File::open(filename)?;
Ok(io::BufReader::new(file).lines()) Ok(io::BufReader::new(file).lines())
} }

View File

@ -3,7 +3,7 @@ use std::io::{self, BufRead};
use std::path::Path; use std::path::Path;
fn main() { fn main() {
let file_path = String::from("/home/wafoo/advent_of_code_2022/aoc_04a/input"); let file_path = String::from("../aoc_04a/input");
let mut result = 0; let mut result = 0;
println!("In file {}", file_path); println!("In file {}", file_path);
@ -24,7 +24,7 @@ fn main() {
result += 1; result += 1;
} }
} }
} }
} }
println!("{}", result); println!("{}", result);
@ -34,4 +34,4 @@ fn read_lines<P>(filename: P) -> io::Result<io::Lines<io::BufReader<File>>>
where P: AsRef<Path>, { where P: AsRef<Path>, {
let file = File::open(filename)?; let file = File::open(filename)?;
Ok(io::BufReader::new(file).lines()) Ok(io::BufReader::new(file).lines())
} }

View File

@ -41,7 +41,7 @@ fn move_array(result: &mut Vec<Vec<char>>, line: String) {
} }
fn main() { fn main() {
let file_path = String::from("/home/wafoo/advent_of_code_2022/aoc_05a/input"); let file_path = String::from("input");
let mut result = Vec::<Vec<char>>::new(); let mut result = Vec::<Vec<char>>::new();
println!("In file {}", file_path); println!("In file {}", file_path);
@ -59,7 +59,7 @@ fn main() {
} }
} }
} }
} }
} }
let mut res = String::from(""); let mut res = String::from("");
@ -73,4 +73,4 @@ fn read_lines<P>(filename: P) -> io::Result<io::Lines<io::BufReader<File>>>
where P: AsRef<Path>, { where P: AsRef<Path>, {
let file = File::open(filename)?; let file = File::open(filename)?;
Ok(io::BufReader::new(file).lines()) Ok(io::BufReader::new(file).lines())
} }

View File

@ -40,7 +40,7 @@ fn move_array(result: &mut Vec<Vec<char>>, line: String) {
} }
fn main() { fn main() {
let file_path = String::from("/home/wafoo/advent_of_code_2022/aoc_05a/input"); let file_path = String::from("../aoc_05a/input");
let mut result = Vec::<Vec<char>>::new(); let mut result = Vec::<Vec<char>>::new();
println!("In file {}", file_path); println!("In file {}", file_path);
@ -58,7 +58,7 @@ fn main() {
} }
} }
} }
} }
} }
let mut res = String::from(""); let mut res = String::from("");
@ -72,4 +72,4 @@ fn read_lines<P>(filename: P) -> io::Result<io::Lines<io::BufReader<File>>>
where P: AsRef<Path>, { where P: AsRef<Path>, {
let file = File::open(filename)?; let file = File::open(filename)?;
Ok(io::BufReader::new(file).lines()) Ok(io::BufReader::new(file).lines())
} }

View File

@ -3,7 +3,7 @@ use std::io::{self, BufRead};
use std::path::Path; use std::path::Path;
fn main() { fn main() {
let file_path = String::from("/home/wafoo/advent_of_code_2022/aoc_06a/input2"); let file_path = String::from("input");
let mut index = 4; let mut index = 4;
println!("In file {}", file_path); println!("In file {}", file_path);
@ -24,7 +24,7 @@ fn main() {
slice = &ip[(index - 4)..index]; slice = &ip[(index - 4)..index];
} }
} }
} }
} }
println!("{}", index); println!("{}", index);
@ -34,4 +34,4 @@ fn read_lines<P>(filename: P) -> io::Result<io::Lines<io::BufReader<File>>>
where P: AsRef<Path>, { where P: AsRef<Path>, {
let file = File::open(filename)?; let file = File::open(filename)?;
Ok(io::BufReader::new(file).lines()) Ok(io::BufReader::new(file).lines())
} }

View File

@ -4,7 +4,7 @@ use std::path::Path;
use std::collections::HashMap; use std::collections::HashMap;
fn main() { fn main() {
let file_path = String::from("/home/wafoo/advent_of_code_2022/aoc_06a/input"); let file_path = String::from("../aoc_06a/input");
let mut index = 14; let mut index = 14;
println!("In file {}", file_path); println!("In file {}", file_path);
@ -24,7 +24,7 @@ fn main() {
index += 1; index += 1;
} }
} }
} }
} }
println!("{}", index - 1); println!("{}", index - 1);
@ -34,4 +34,4 @@ fn read_lines<P>(filename: P) -> io::Result<io::Lines<io::BufReader<File>>>
where P: AsRef<Path>, { where P: AsRef<Path>, {
let file = File::open(filename)?; let file = File::open(filename)?;
Ok(io::BufReader::new(file).lines()) Ok(io::BufReader::new(file).lines())
} }