Implement calculation of most efficient layout of tokens