i:"-"\'0:"i/23.in"
a:=!/+(n:?,/i)?/:i,|'i                      / adjacency list, computer names
s:{(1=+/1&/''~^x?/:\:)#x}@?:                / remove elements that are subsets of others
c:n@(,!0){s@x,y,'(|/'y=a@)#'x}/!#n          / cliques
+/*'|/'"t"=(3=#:')#?{?x@<x}',/{x@+!3##x}'c  / part 1: cliques of size 3 with a "t" computer
`0:","/l@<l:c@*>#'c                         / part 2: largest clique

Graph theory, my favourite...

Part 1 is a bit messy. I have a list of all cliques, but then I need to find all cliques of size 3. I couldn't think of a better way of doing this than generating all size 3 subsets of each clique, then deduping.

The clique finding can be made about 10x faster by using something like
c:n@(,!0){((&/'|/''y=a@)_x),y,'s(|/'y=a@)#'x}/!#n
but it's a lot nastier and just manually expanding out what's happening.

ovs uses similar logic to me, but executes it much better.


~/aoc24k/23.html