- commit
- a16895888436a4f10233b8e0500ae264a38c79ce
- parent
- df2f786f3fe1f9a876a988ffc74e03554d533983
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2022-12-18 06:34
simplify: use Vec instead of HashSet
Diffstat
M | 2022/17/solution.rs | 10 | +++++----- |
1 files changed, 5 insertions, 5 deletions
diff --git a/2022/17/solution.rs b/2022/17/solution.rs
@@ -7,10 +7,10 @@ use std::convert::TryInto; 7 7 const WIDTH: usize = 7; 8 8 9 9 struct Shape {10 -1 blocks: HashSet<(usize, usize)>,11 -1 bottom: HashSet<(usize, usize)>,12 -1 left: HashSet<(usize, usize)>,13 -1 right: HashSet<(usize, usize)>,-1 10 blocks: Vec<(usize, usize)>, -1 11 bottom: Vec<(usize, usize)>, -1 12 left: Vec<(usize, usize)>, -1 13 right: Vec<(usize, usize)>, 14 14 width: usize, 15 15 height: usize, 16 16 } @@ -25,7 +25,7 @@ struct CacheKey { 25 25 26 26 fn make_shape(blocks: Vec<(usize, usize)>) -> Shape { 27 27 return Shape {28 -1 blocks: blocks.iter().map(|(x, y)| (*x, *y)).collect(),-1 28 blocks: blocks.clone(), 29 29 bottom: blocks.iter().filter(|(x, y)| *y == 0 || !blocks.contains(&(*x, *y - 1))).map(|(x, y)| (*x, *y)).collect(), 30 30 left: blocks.iter().filter(|(x, y)| *x == 0 || !blocks.contains(&(*x - 1, *y))).map(|(x, y)| (*x, *y)).collect(), 31 31 right: blocks.iter().filter(|(x, y)| !blocks.contains(&(*x + 1, *y))).map(|(x, y)| (*x, *y)).collect(),