Words 1 X11585


Statement
 

pdf   zip

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 iterative 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.

Public test cases
  • Input

    1
    G T A C
    

    Output

    A
    C
    G
    T
    
  • Input

    2
    G T A C
    

    Output

    AA
    AC
    AG
    AT
    CA
    CC
    CG
    CT
    GA
    GC
    GG
    GT
    TA
    TC
    TG
    TT
    
  • Input

    3
    G T A C
    

    Output

    AAA
    AAC
    AAG
    AAT
    ACA
    ACC
    ACG
    ACT
    AGA
    AGC
    AGG
    AGT
    ATA
    ATC
    ATG
    ATT
    CAA
    CAC
    CAG
    CAT
    CCA
    CCC
    CCG
    CCT
    CGA
    CGC
    CGG
    CGT
    CTA
    CTC
    CTG
    CTT
    GAA
    GAC
    GAG
    GAT
    GCA
    GCC
    GCG
    GCT
    GGA
    GGC
    GGG
    GGT
    GTA
    GTC
    GTG
    GTT
    TAA
    TAC
    TAG
    TAT
    TCA
    TCC
    TCG
    TCT
    TGA
    TGC
    TGG
    TGT
    TTA
    TTC
    TTG
    TTT
    
  • Information
    Author
    Gabriel Valiente
    Language
    English
    Official solutions
    C++ Python
    User solutions
    C++ Python