I think my solution contained the most horrible kludges I've done in AoC in ages, and that's saying a lot.