Solution to the voting problem