(r;u):.''"\n"\'"\n\n"\" "/"|"\1:"i/5.in"  / rules, updates
g:{(!d)@>#'.d:=*'(|/'^x?)_r}'u            / correctly order each update (without the last element)
+/'(g@'-2!#'g)*/:~:\g~'-1_'u              / sum the centre elements of the correct and corrected updates separately

This orders pages by tracking "before" frequencies in all the applicable rules. The first page will have the most left hand side rule appearances, since the rules must place it before all the other pages, etc.

I didn't know the dict trick at the time...


~/aoc24k/5.html