Skip to content

Commit 7d0de0d

Browse files
committed
Fix code smells in previous days
1 parent a05602a commit 7d0de0d

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

src/bin/day19.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ impl SearchNode {
8989
}
9090

9191
fn utility(&self) -> usize {
92-
self.resources[GEODE] as usize
92+
self.resources[GEODE]
9393
}
9494

9595
fn expand(&self, costs: &Blueprint) -> Vec<SearchNode> {
@@ -206,7 +206,8 @@ fn compute_bound(
206206
.min(dt)
207207
/ 2;
208208

209-
spec_geode as usize
209+
#[allow(clippy::let_and_return)]
210+
spec_geode
210211
}
211212

212213
fn parse_res(s: &str) -> Res {

src/bin/day24.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ fn search_sol(map: Map) -> (Map, usize) {
383383
frontier.push(SearchNode::new(&map_t[0]));
384384

385385
// Search
386-
let mut sol: usize = usize::MAX;
386+
let mut cost: usize = usize::MAX;
387387
while let Some(node) = frontier.pop() {
388388
if visited.contains(&node) {
389389
continue;
@@ -393,7 +393,7 @@ fn search_sol(map: Map) -> (Map, usize) {
393393
// goal
394394
if node.pos == map_t[0].end {
395395
println!("Solution: {}", node);
396-
sol = node.t;
396+
cost = node.t;
397397
break;
398398
}
399399

@@ -405,7 +405,7 @@ fn search_sol(map: Map) -> (Map, usize) {
405405
}
406406
visited.insert(node);
407407
}
408-
(map_t.remove(sol), sol)
408+
(map_t.remove(cost), cost)
409409
}
410410

411411
fn main() {

src/bin/day9.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ impl Sub<Pos> for Pos {
1919
type Output = Pos;
2020
fn sub(self, rhs: Pos) -> Self::Output {
2121
Pos(
22-
(self.0 - rhs.0).min(1).max(-1),
23-
(self.1 - rhs.1).min(1).max(-1),
22+
(self.0 - rhs.0).clamp(-1, 1),
23+
(self.1 - rhs.1).clamp(-1, 1),
2424
)
2525
}
2626
}

0 commit comments

Comments
 (0)