Skip to content

Commit

Permalink
upperf
Browse files Browse the repository at this point in the history
  • Loading branch information
alion02 committed Dec 24, 2024
1 parent 52fb0d6 commit 2031421
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/day23.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,18 @@ unsafe fn inner2(s: &str) -> String {
let mut pass = HashSet::new();
for &(a, b) in &connections {
let intersection = graph[a].intersection(&graph[b]).collect::<Vec<_>>();
for i in 0..intersection.len() {
let mut clique = HashSet::from_iter([a, b]);
for &new in &intersection[i..] {
if clique.contains(new) {
continue;
}
if graph[new].intersection(&clique).count() == clique.len() {
clique.insert(new);
}
let mut clique = HashSet::from_iter([a, b]);
for &new in &intersection {
if clique.contains(new) {
continue;
}
if clique.len() > pass.len() {
pass = clique;
if graph[new].intersection(&clique).count() == clique.len() {
clique.insert(new);
}
}
if clique.len() > pass.len() {
pass = clique;
}
}
let mut pass = pass.iter().collect::<Vec<_>>();
pass.sort_unstable();
Expand Down

0 comments on commit 2031421

Please sign in to comment.