From 1ff920f2c3e4f63f3c742fe96f336543b42aa978 Mon Sep 17 00:00:00 2001 From: JasterV Date: Tue, 7 Dec 2021 23:29:06 +0100 Subject: [PATCH] refactor --- day3/src/main.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/day3/src/main.rs b/day3/src/main.rs index 9b4e835..a4f00a1 100644 --- a/day3/src/main.rs +++ b/day3/src/main.rs @@ -24,8 +24,8 @@ fn extract_report_rates(report: &[String]) -> [i32; 4] { let oxygen_rate = filter_report_while( report, |report, iteration| { - filter_report_by_nums_bit(report, iteration, |sum, c| { - sum >= 0 && c == '1' || sum < 0 && c == '0' + filter_report_by_nums_bit(report, iteration, |bit_sums, curr_bit| { + bit_sums >= 0 && curr_bit == '1' || bit_sums < 0 && curr_bit == '0' }) }, |report, iteration| report.len() == 1 || iteration > sums.len(), @@ -36,8 +36,8 @@ fn extract_report_rates(report: &[String]) -> [i32; 4] { let co2_rate = filter_report_while( report, - |report, iteration| { - filter_report_by_nums_bit(report, iteration, |bit_sums, curr_bit| { + |report, bit_index| { + filter_report_by_nums_bit(report, bit_index, |bit_sums, curr_bit| { bit_sums >= 0 && curr_bit == '0' || bit_sums < 0 && curr_bit == '1' }) },