Words with x, y and z X20680


Statement
 

pdf   zip

html

In this problem we will consider words of size n, made from letters ‘x’, ‘y’ and ‘z’, and without more than c equal consecutive letters. Write a program that writes all words that satisfy these constraints.

Input

Input consists of several cases, each with an n between 1 and 15 and a c between 1 and n.

Output

For each case, write in alphabetical order all words of length n made from letters ‘x’, ‘y’ and ‘z’ that do not contain c+1 equal consecutive letters. Write a line with 20 hyphens at the end of each case.

Public test cases
  • Input

    1 1
    2 2
    3 1
    

    Output

    x
    y
    z
    --------------------
    xx
    xy
    xz
    yx
    yy
    yz
    zx
    zy
    zz
    --------------------
    xyx
    xyz
    xzx
    xzy
    yxy
    yxz
    yzx
    yzy
    zxy
    zxz
    zyx
    zyz
    --------------------
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Translator
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++
    User solutions
    C++