Download Tiling

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Document related concepts

Diff wikipedia, lookup

Types of artificial neural networks wikipedia, lookup

Delta-sigma modulation wikipedia, lookup

Corecursion wikipedia, lookup

Pattern recognition wikipedia, lookup

SahysMod wikipedia, lookup

Nonblocking minimal spanning switch wikipedia, lookup

Transcript
Tiling
Filename: tile
The Problem
You are given a nx1 rectangle to tile with 1x1 and 2x1 tiling pieces. Write a program to
print out all the different ways to tile the nx1 rectangle, given a particular value of n. For
example, for n=5, your program should produce the 8 following tilings:
2,2,1
2,1,2
2,1,1
1,2,2
1,2,1,1
1,1,2,1
1,1,1,2
1,1,1,1,1
The order in which they should be produced is that tilings with a larger first tile should go
first. If there is a tie between first tiles, then continue comparing corresponding tiles until
there is a difference between the two.
The Input
The first line of the input file will contain a single positive integer, n, representing the
number of test cases in the file. The following n lines will contain one positive integer
each, less than 16.
The Output
For each input case, list all of the tilings, one per line. A single tiling is a list of the
lengths of the tiles in order separated by commas. Separate the output for each case with
a blank line.
Sample Input
2
1
3
Sample Output
1
2,1
1,2
1,1,1