Skip to content

Commit bdac83f

Browse files
committed
With sorts
1 parent 5d2a06e commit bdac83f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/day23.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use aoc_runner_derive::aoc;
55
const MAX: usize = 26 * 26;
66

77
const T_START: u16 = (b't' - b'a') as u16 * 26;
8-
const T_END: u16 = T_START + 26;
98

109
const T_START_REM: u16 = (-(T_START as i16)).rem_euclid(MAX as i16) as u16;
1110

@@ -34,6 +33,9 @@ pub fn part1(s: &str) -> u64 {
3433
i += 6;
3534
}
3635

36+
for c in connections.iter_mut() {
37+
c.sort_unstable_by(|a, b| b.cmp(a));
38+
}
3739
// println!(
3840
// "{}{}:",
3941
// ((c / 26) as u8 + b'a') as char,
@@ -44,11 +46,11 @@ pub fn part1(s: &str) -> u64 {
4446
for c in 0..26 {
4547
for con in &connections[c as usize] {
4648
if *con < c {
47-
continue;
49+
break;
4850
}
4951
for concon in &connections[*con as usize] {
5052
if *concon < *con {
51-
continue;
53+
break;
5254
}
5355
for conconcon in &connections[*concon as usize] {
5456
if *conconcon == c {

0 commit comments

Comments
 (0)