Solution to Rosalind CONS problem