diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-07-09 10:23:07 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-07-09 10:23:07 +0200 |
| commit | 9637b5a1f8d10e3003651c5d9006f0e102f74f18 (patch) | |
| tree | b9b532c6744f1dd1c4359783ab41f37768c81269 /2022/23/a.rs | |
| parent | dbb5a4e5711fba371fbb011356bcd8a28cc963e4 (diff) | |
| download | aoc-9637b5a1f8d10e3003651c5d9006f0e102f74f18.tar.gz aoc-9637b5a1f8d10e3003651c5d9006f0e102f74f18.zip | |
Day 23 2022
Diffstat (limited to '2022/23/a.rs')
| -rw-r--r-- | 2022/23/a.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/2022/23/a.rs b/2022/23/a.rs new file mode 100644 index 0000000..906dde7 --- /dev/null +++ b/2022/23/a.rs | |||
| @@ -0,0 +1,24 @@ | |||
| 1 | use std::cmp::{min, max}; | ||
| 2 | mod common; | ||
| 3 | use common::*; | ||
| 4 | |||
| 5 | fn size(elves: &Vec<(i64, i64)>) -> usize { | ||
| 6 | let mut imax = i64::MIN; | ||
| 7 | let mut jmax = i64::MIN; | ||
| 8 | let mut imin = i64::MAX; | ||
| 9 | let mut jmin = i64::MAX; | ||
| 10 | for e in elves { | ||
| 11 | imax = max(imax, e.0); | ||
| 12 | jmax = max(jmax, e.1); | ||
| 13 | imin = min(imin, e.0); | ||
| 14 | jmin = min(jmin, e.1); | ||
| 15 | } | ||
| 16 | ((imax-imin+1) * (jmax-jmin+1)) as usize | ||
| 17 | } | ||
| 18 | |||
| 19 | fn main() { | ||
| 20 | let (mut elves, mut lookup) = read_from_stdin(); | ||
| 21 | let _ = play(&mut elves, &mut lookup, 10); | ||
| 22 | let result = size(&elves) - elves.len(); | ||
| 23 | println!("{result}"); | ||
| 24 | } | ||
