brittle longest-prefix solution. passes a single test...