Skip to content

Commit 599a1b3

Browse files
authored
refactor in norinori.rs and milktea.rs (#208)
1 parent 5144147 commit 599a1b3

2 files changed

Lines changed: 1 addition & 17 deletions

File tree

cspuz_rs_puzzles/src/puzzles/milktea.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,6 @@ pub fn solve_milktea(clues: &[Vec<i32>]) -> Option<graph::BoolGridEdgesIrrefutab
1717
let is_center = &solver.bool_var_2d((h, w));
1818
for y in 0..h {
1919
for x in 0..w {
20-
let mut adj = vec![];
21-
22-
if y > 0 {
23-
adj.push(is_line.vertical.at((y - 1, x)));
24-
}
25-
if x > 0 {
26-
adj.push(is_line.horizontal.at((y, x - 1)));
27-
}
28-
if y < h - 1 {
29-
adj.push(is_line.vertical.at((y, x)));
30-
}
31-
if x < w - 1 {
32-
adj.push(is_line.horizontal.at((y, x)));
33-
}
34-
3520
let n = &solver.int_var(0, 3);
3621
solver.add_expr(is_line.vertex_neighbors((y, x)).count_true().eq(n));
3722

cspuz_rs_puzzles/src/puzzles/norinori.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ pub fn solve_norinori(
1616
let rooms = graph::borders_to_rooms(borders);
1717

1818
for room in &rooms {
19-
let cells = room.iter().map(|&p| is_black.at(p)).collect::<Vec<_>>();
20-
solver.add_expr(count_true(cells).eq(2));
19+
solver.add_expr(is_black.select(room).count_true().eq(2));
2120
}
2221
for y in 0..h {
2322
for x in 0..w {

0 commit comments

Comments
 (0)