7th solution (with cheat, lol)
8th solution