Words 2

Nucleic acid sequences are labeled over the alphabet {A,C,G,T}\{A,C,G,T\}, and there are 4n4^n possible genomic sequences of length nn. Amino acid sequences, on the other hand, are labeled over the alphabet {A,C,D,E,F,G,H,I,K,L,M,N,P,Q,R,S,T,V,W,Y}\{A,C,D,E,F,G,H,I,K,L,M,N,P,Q,R,S,T,V,W,Y\}, and there are 20n20^n possible proteomic sequences of length nn. An interesting problem is the generation of all the genomic sequences with nn nucleotides or all the proteomic sequences with nn amino acids, that is, the generation of all the words of length nn over an alphabet Σ\Sigma.

Write code for the words problem. The program must implement and use the WORDS function in the pseudocode discussed in class, which is recursive and is not allowed to perform input/output operations. Make one submission with Python code and another submission with C++ code.

Input

The input is an integer nn and an alphabet Σ\Sigma.

Output

The output is a sorted list of all the words of length nn over the alphabet Σ\Sigma.

Problem information

Author: Gabriel Valiente

Generation: 2026-01-25T16:54:22.413Z

© Jutge.org, 2006–2026.
https://jutge.org