welcome: please sign in

Upload page content

You can upload content for the page named below. If you change the page name, you can also upload content for another page. If the page name is empty, we derive the page name from the file name.

File to load page content from
Page name
Comment

location: FinalProblemDescriptions / Tangram

Tangram

Problem Description

Tangram is an ancient Chinese game of Shapes. The goal is to form a particular shape from a set of seven pieces consisting of 5 triangles (of three different sizes), a square, and a parallelogram. These seven pieces are defined below, where the 1-st argument is the block number (an integer identifier), the 2-nd argument is the number k of sides of the block, and the last 2*k arguments represents the vertices of the block.

size_block(1,3, 0,0, 4,0, 2,2). %%% Large triangle 
size_block(2,3, 0,0, 4,0, 2,2). %%% Large triangle 
size_block(3,3, 0,0, 2,0, 0,2). %%% Medium triangle
size_block(4,3, 0,0, 2,0, 1,1). %%% Small triangle 
size_block(5,3, 0,0, 2,0, 1,1). %%% Small triangle 
size_block(6,4, 0,0, 1,-1, 2,0, 1,1). %%% Square 
size_block(7,4, 0,0, 1,1,  1,3, 0,2). %%% Parallelogram 

Note that these facts are not part of the input.

Allowed angles are 0 (0), 45 (1), 90 (2), 135 (3), 180 (4), 225 (5), 270 (6), and 315 (7) degrees, represented by means of the numbers 0..7 in parenthesis.

Predicates

Input format

A fact of the form sides(n), fixing the number of sides of the figure.

The target shape is specified by means of n facts of the form

coord(1,X1,Y1). 
coord(2,X2,Y2). 
...             
coord(n,Xn,Yn). 

In particular, a fact of the form coord(i,Xi,Yi) specifies that the i-th vertex of the target shape is (Xi,Yi). Thus, the perimeter of the figure is the set of segments  { (X1,Y1)-(X2,Y2), (X2,Y2)-(X3,Y3), ..., (Xn-1,Yn-1)-(Xn,Yn), (Xn-Yn)-(X1,Y1) } .

In our setting, each coordinate X is an integer in {0,...,8}, and each coordinate Y is an integer in {0,...,6}.

Output format

Your program needs to compute a predicate put/4 that associates to each block i in {1,...,7} one pair (X,Y) and one angle A. With that association the entire surface of the instance figure must be covered (and without overlapping, but this is a consequence for the chosen figures). More specifically, an atom of the form put(i,x,y,r) in the output specifies that the block with ID i is positioned in (x,y) and rotated according to r.

Example(s)

Input: sides(3). coord(1,0,0). coord(2,8,0). coord(3,4,4).

Output: put(1,4,0,0). put(2,4,4,6). put(3,4,0,2). put(4,0,0,0). put(5,3,1,2). put(6,1,1,0). put(7,3,1,0).

Author(s)