added trim_end because of windows

This commit is contained in:
2024-12-08 17:49:26 +01:00
parent e6f4cbcac7
commit 14ea60b823
6 changed files with 6 additions and 6 deletions

View File

@@ -14,7 +14,7 @@ pub fn day01a() -> u64 {
// parse file
file_content.split("\n").enumerate().for_each(|(line_nr, line)| {
let mut split = line.split(" ");
let mut split = line.trim_end().split(" ");
list_a[line_nr] = split.next().unwrap().parse::<i32>().unwrap();
list_b[line_nr] = split.next().unwrap().parse::<i32>().unwrap();
});

View File

@@ -14,7 +14,7 @@ pub fn day01b() -> u64 {
// parse file
file_content.split("\n").enumerate().for_each(|(line_nr, line)| {
let mut split = line.split(" ");
let mut split = line.trim_end().split(" ");
list_a[line_nr] = split.next().unwrap().parse::<i32>().unwrap();
list_b[line_nr] = split.next().unwrap().parse::<i32>().unwrap();
});

View File

@@ -11,7 +11,7 @@ pub fn day02a() -> u64 {
let mut nr_or_correct_reports: u64 = 0;
// iterate over all reports
file_content.split("\n").for_each(|report| {
let levels: Vec<i32> = report.split(" ").map(|level| level.parse::<i32>().unwrap()).collect();
let levels: Vec<i32> = report.trim_end().split(" ").map(|level| level.parse::<i32>().unwrap()).collect();
let mut trend: i32 = 0;
let mut safe: bool = true;
// iterate over all levels and ty to find a trend

View File

@@ -11,7 +11,7 @@ pub fn day02b() -> u64 {
let mut nr_or_correct_reports: u64 = 0;
// iterate over all reports
file_content.split("\n").for_each(|report| {
let levels: Vec<i32> = report.split(" ").map(|level| level.parse::<i32>().unwrap()).collect();
let levels: Vec<i32> = report.trim_end().split(" ").map(|level| level.parse::<i32>().unwrap()).collect();
let mut trend: i32 = 0;
let mut safe: i32 = 2;
// iterate over all levels and ty to find a trend

View File

@@ -10,7 +10,7 @@ pub fn day04a() -> u64 {
// create n*n matrix from input
let mut matrix: [[char; 140]; 140] = [[' '; 140]; 140];
file_content.split("\n").enumerate().for_each(|(line_nr, line)| {
line.chars().enumerate().for_each(|(col_nr, ch)| {
line.trim_end().chars().enumerate().for_each(|(col_nr, ch)| {
matrix[line_nr][col_nr] = ch;
});
});

View File

@@ -10,7 +10,7 @@ pub fn day04b() -> u64 {
// create n*n matrix from input
let mut matrix: [[char; 140]; 140] = [[' '; 140]; 140];
file_content.split("\n").enumerate().for_each(|(line_nr, line)| {
line.chars().enumerate().for_each(|(col_nr, ch)| {
line.trim_end().chars().enumerate().for_each(|(col_nr, ch)| {
matrix[line_nr][col_nr] = ch;
});
});