Knight jumps P98620


Statement
 

pdf   zip

thehtml

Given a board with three columns and n rows, find a way for a chess knight to visit exactly 3n − 2 cells, starting at any cell, and never repeating any cell nor going outside the board.

Input

Input consists of several cases, each with an n between 3 and 105.

Output

Print one line for each case, with any solution. Columns are labelled with ‘a’, ‘b’ and ‘c’ in this order, while rows are numbered from 1 to n. Follow strictly the format of the sample output.

Public test cases
  • Input

    5
    3
    

    Output

    c5->a4->c3->b1->a3->c4->a5->b3->c1->a2->b4->c2->a1
    a1->c2->a3->b1->c3->a2->c1
    
  • Information
    Author
    Xavier Povill
    Language
    English
    Official solutions
    C++
    User solutions
    C++