Given an amino acid string Peptide, its ideal spectrum, denoted IdealSpectrum(Peptide), is the collection of integer masses of all its prefixes and suffixes. Note that an ideal spectrum may have repeated masses; for example, IdealSpectrum(GPG) = {0, 57, 57, 154, 154, 211}. We say that an amino acid string Peptide explains a collection of integers Spectrum if IdealSpectrum(Peptide) = Spectrum.
The following pseudocode finds a peptide explaining a given spectrum.
Given a space-delimited list of integers, Spectrum.
Return an amino acid string with an ideal spectrum that matches Spectrum.
>>> decoding_ideal_spectrum([57, 103, 160, 160]) 'GC' >>> decoding_ideal_spectrum([71, 163, 257, 326, 420, 512, 583, 583]) 'AWYY'