Both the bruteforce and elegant solutions seem to be working. Still have some BC weirdness.