Skip to content

Commit

Permalink
rename function
Browse files Browse the repository at this point in the history
  • Loading branch information
BakerNet committed Dec 12, 2023
1 parent b0a1cd4 commit 713f94a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/bin/12.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fn parse_record(line: &str) -> (String, Vec<usize>) {
// 0
// }

fn possible_arrangements2(
fn possible_arrangements_dp(
items: &String,
damaged: &Vec<usize>,
item_pos: usize,
Expand All @@ -79,15 +79,15 @@ fn possible_arrangements2(
}
let dot_ans = |seen: &mut HashMap<(usize, usize, usize), usize>| {
if curr_block_size == 0 {
possible_arrangements2(items, damaged, item_pos + 1, damaged_pos, 0, seen)
possible_arrangements_dp(items, damaged, item_pos + 1, damaged_pos, 0, seen)
} else if damaged_pos < damaged.len() && curr_block_size == damaged[damaged_pos] {
possible_arrangements2(items, damaged, item_pos + 1, damaged_pos + 1, 0, seen)
possible_arrangements_dp(items, damaged, item_pos + 1, damaged_pos + 1, 0, seen)
} else {
0
}
};
let hash_ans = |seen: &mut HashMap<(usize, usize, usize), usize>| {
possible_arrangements2(
possible_arrangements_dp(
items,
damaged,
item_pos + 1,
Expand All @@ -111,7 +111,7 @@ pub fn part_one(input: &str) -> Option<u64> {
.lines()
.map(parse_record)
.map(|(items, damaged)| {
possible_arrangements2(&items, &damaged, 0, 0, 0, &mut HashMap::new())
possible_arrangements_dp(&items, &damaged, 0, 0, 0, &mut HashMap::new())
})
.collect();
Some(num_arrangements.iter().sum::<usize>() as u64)
Expand All @@ -130,7 +130,7 @@ pub fn part_two(input: &str) -> Option<u64> {
.map(parse_record)
.map(|(items, damaged)| parse_part2(items, damaged))
.map(|(items, damaged)| {
possible_arrangements2(&items, &damaged, 0, 0, 0, &mut HashMap::new())
possible_arrangements_dp(&items, &damaged, 0, 0, 0, &mut HashMap::new())
})
.collect();
Some(num_arrangements.iter().sum::<usize>() as u64)
Expand Down

0 comments on commit 713f94a

Please sign in to comment.