constant time solution to Part Elf GCJ problem