logicpuzzle

A LaTeX style file for typesetting logic puzzles

User Tools

Site Tools


skyline

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

skyline [2015/09/06 09:52] (current)
Line 1: Line 1:
 +<​markdown>​
 +Skyline
 +=======
  
 +The puzzle
 +----------
 +
 +There are skyscrapers located in each cell. Try to find out the height
 +of the skyscraper in the respective cell. There are heights of 1 to MAX
 +in every row, every column, and in each of the two diagonals if
 +indicated. Some cells may be empty (parks). The numbers around the grid
 +indicate how many buildings you can see from this position when you look
 +at the skyscraper lineup. Bear in mind that only those skyscrapers are
 +visible which are higher than the ones in front. Here’s a little
 +self-explanatory example:
 +
 +![Skyline](http://​i.imgur.com/​BEBClaz.png)
 +
 +    \begin{center}
 +      \begin{skyline}
 +        \skylineB{3,​{},​3,​1,​{}}
 +        \skylineL{{},​4,​3,​{},​{}}
 +        \skylineT{{},​{},​2,​{},​3}
 +        \skylineR{{},​1,​3,​{},​{}}
 +        \skylinecell{1}{3}{2}
 +        \skylinecell{4}{2}{3}
 +      \end{skyline}
 +      \hspace{1cm}
 +      \begin{skyline}
 +        \skylineB{3,​{},​3,​1,​{}}
 +        \skylineL{{},​4,​3,​{},​{}}
 +        \skylineT{{},​{},​2,​{},​3}
 +        \skylineR{{},​1,​3,​{},​{}}
 +        \setrow{5}{5,​4,​3,​1,​2}
 +        \setrow{4}{4,​5,​1,​2,​3}
 +        \setrow{3}{2,​3,​5,​4,​1}
 +        \setrow{2}{1,​2,​4,​3,​5}
 +        \setrow{1}{3,​1,​2,​5,​4}
 +      \end{skyline}
 +    \end{center}
 +
 +Options
 +-------
 +
 ++ `rows (5)`
 +defines the number of rows in the grid
 +
 ++ `columns (5)`
 +specifies the number of columns in the grid
 +
 ++ `sudoku (false)`
 +sets `rows` and `columns` to 9, in case **true** is specified. Additionally the classic Sudoku grid is drawn
 +
 ++ `width (6.7cm)`
 +sets the width of the minipage, in which the grid is typeset
 +
 ++ `scale (1)`
 +scales the size of the grid in the minipage
 +
 ++ `fontsize (Large)`
 +specifies the size of the numbers next to the grid. Here, the usual LaTeX sizes are used. Possible values: tiny, scriptsize, footnotesize,​ small, normalsize, large, **Large**, LARGE, huge, Huge
 +
 ++ `title ()`
 +sets the title of a puzzle
 +
 ++ `titleindent (0.75cm)`
 +defines the indent of the title
 +
 ++ `titlewidth (5.85cm)`
 +specifies the width of the box the title is set in
 +
 ++ `bgcolor ()`
 +sets the background color of the grid
 +
 ++ `counterstyle (none)`
 +defines the counter style. Predefined styles: **none**, left, right
 +
 ++ `cvoffset (-39pt)`
 +sets the vertical offset of the counters in the margin
 +
 +Environments
 +------------
 +
 +###skyline
 +
 +
 +    \begin{skyline}[options]
 +
 +    \end{skyline}
 +
 +The `skyline` environment is the central core of the style file. With the optional
 +argument of the environment,​ you can reset the options with local scope.
 +Here, a blank grid is created.
 +
 +###​puzzlebackground
 +
 +    \begin{puzzlebackground}
 +
 +    \end{puzzlebackground}
 +
 +The `puzzlebackground` environment allows you to place elements behind the main layer. This
 +is for example usefull for the `\fillarea` command.
 +
 +###​puzzleforeground
 +
 +    \begin{puzzleforeground}
 +
 +    \end{puzzleforeground}
 +
 +The `puzzleforeground` environment allows you to place elements in front of the main layer.
 +This is for example usefull for the `\framearea` command.
 +
 +Commands
 +--------
 +
 +###In the grid and around
 +
 +#### skylineT
 +
 +`\skylineT{csv list}`
 +
 +The command typesets the numbers above the grid indicating how many
 +skycrapers are visible. It expects a comma-separated list as an
 +argument.
 +
 +#### skylineB
 +
 +`\skylineB{csv list}`
 +
 +The command typesets the numbers below the grid.
 +
 +#### skylineL
 +
 +`\skylineL{csv list}`
 +
 +The command typesets the numbers left to the grid.
 +
 +#### skylineR
 +
 +`\skylineR{csv list}`
 +
 +The command typesets the numbers right to the grid.
 +
 +#### skylinecell
 +
 +`\skylinecell{column}{row}{height}`
 +
 +The command sets the `{height}` of the grid cell `{column}{row}`.
 +
 +#### setrow
 +
 +`\setrow{row}{csv list}`
 +
 +The command sets the heights of `{row}`. It expects a comma-separated list.
 +
 +#### setcolumn
 +
 +`\setcolumn{column}{csv list}`
 +
 +The command sets the heights of `{column}`.
 +
 +#### framearea
 +
 +`\framearea{color}{\tikz path}`
 +
 +The command frames the area given by `{\tikz path}` with color `{color}`. The reference for
 +coordinates is the bottom left corner of the cell.
 +
 +`\framearea{green}{(2,​2)--(2,​3)--(3,​3)--(3,​2)--(2,​2)}`
 +
 +This command will color the frame of the grid cell `(2,2)` green. You
 +should consider using this command in the `puzzleforeground` environment.
 +
 +#### fillarea
 +
 +`\fillarea{color}{\tikz path}`
 +
 +The command fills the area given by `{\tikz path}` with color `{color}`. The reference for
 +coordinates is the bottom left corner of the cell. You should consider
 +using this command in the `puzzlebackground` environment.
 +
 +###​Presentation
 +
 +#### definecounterstyle
 +
 +The command allows you to define your own styles. For example, the style
 +`left` is defined as follows:
 +
 +    \definecounterstyle{left}{
 +      \begingroup\reversemarginpar\marginnote{
 +      \tikz\node[shape=rectangle,​fill=yellow!40,​inner sep=7pt,
 +                 ​draw,​rounded corners=3pt,​thick]
 +      {\Huge\puzzlecounter};​}[\LP@cvoffset]\endgroup}
 +    }
 +
 +To typeset the counter into the margin we use the command `\marginnote`. We need to
 +use the command `\reversemarginpar` to set the counter into the left margin. Of course, we
 +must use this command in a group for local scope. Finally we use `\puzzlecounter` in a
 +`\tikz` node with a vertical offset set with the option `cvoffset`.
 +
 +#### puzzlecounter
 +
 +`\puzzlecounter`
 +
 +The command provides the counter in textual form to use it for example
 +in `\definecounterstyle`.
 +
 +#### titleformat
 +
 +`\titleformat{format}`
 +
 +With the command `\titleformat`,​ you can define the format of the title. By default,
 +the definition is as follows:
 +
 +`\titleformat{\centering\Large\color{blue}}`
 +
 +###​Miscellaneous
 +
 +#### skylinesetup
 +
 +`\skylinesetup{options}`
 +
 +With the command you can reset the options with global scope.
 +
 +#### setpuzzlecounter
 +
 +`\setpuzzlecounter{number}`
 +
 +With the command `\setpuzzlecounter`,​ you can reset the puzzle counter, for example before
 +the solutions.
 +
 +Supported variants
 +------------------
 +
 +###Skyline Sudoku
 +
 +![Skyline Sudoku](http://​i.imgur.com/​tIoe3QK.png)
 +
 +    \begin{center}
 +      \begin{skyline}[sudoku,​scale=.46]
 +        \skylineB{4,​5,​2,​5,​2,​1,​2,​4,​3}
 +        \skylineL{4,​2,​2,​2,​1,​3,​3,​3,​2}
 +        \skylineT{4,​1,​3,​2,​3,​5,​3,​2,​3}
 +        \skylineR{3,​3,​1,​3,​4,​2,​3,​2,​4}
 +        \setrow{9}{{},​{},​{},​8,​{},​{},​{},​7}
 +        \setrow{8}{{},​{},​4,​{},​{},​6,​{},​{},​8}
 +        \setrow{7}{{},​2,​{},​7,​{},​{},​{},​{},​1}
 +        \setrow{6}{{},​{},​{},​{},​8,​2}
 +        \setrow{5}{{},​{},​2,​{},​4,​{},​7}
 +        \setrow{4}{{},​{},​{},​3,​{},​{},​4}
 +        \setrow{3}{{},​{},​{},​{},​1}
 +        \setrow{2}{{},​3,​{},​{},​{},​{},​1,​2}
 +        \setrow{1}{{},​{},​5}
 +      \end{skyline}
 +      \hspace{1cm}
 +      \begin{skyline}[sudoku,​scale=.46]
 +        \skylineB{4,​5,​2,​5,​2,​1,​2,​4,​3}
 +        \skylineL{4,​2,​2,​2,​1,​3,​3,​3,​2}
 +        \skylineT{4,​1,​3,​2,​3,​5,​3,​2,​3}
 +        \skylineR{3,​3,​1,​3,​4,​2,​3,​2,​4}
 +        \setrow{9}{3,​9,​6,​8,​5,​1,​2,​7,​4}
 +        \setrow{8}{1,​7,​4,​9,​2,​6,​3,​5,​8}
 +        \setrow{7}{5,​2,​8,​7,​3,​4,​9,​6,​1}
 +        \setrow{6}{7,​4,​3,​1,​8,​2,​6,​9,​5}
 +        \setrow{5}{9,​8,​2,​6,​4,​5,​7,​1,​3}
 +        \setrow{4}{6,​5,​1,​3,​9,​7,​4,​8,​2}
 +        \setrow{3}{8,​6,​7,​2,​1,​3,​5,​4,​9}
 +        \setrow{2}{4,​3,​9,​5,​6,​8,​1,​2,​7}
 +        \setrow{1}{2,​1,​5,​4,​7,​9,​8,​3,​6}
 +      \end{skyline}
 +    \end{center}
 +
 +###Skyline Sudoku (N\*N)
 +
 +![Skyline Sudoku (N*N)](http://​i.imgur.com/​6k4nDF8.png)
 +
 +    \begin{center}
 +      \begin{skyline}[rows=6,​columns=6,​scale=.65]
 +        \skylineB{4,​2,​1,​3,​3,​2}
 +        \skylineL{3,​3,​4,​3,​2,​1}
 +        \skylineT{1,​2,​3,​3,​2,​4}
 +        \skylineR{4,​1,​2,​2,​2,​3}
 +        \skylinecell{2}{4}{1}
 +        \skylinecell{4}{1}{4}
 +        \skylinecell{5}{2}{3}
 +        \begin{puzzlebackground}
 +          \fillarea{Wheat}{(1,​1)--(1,​3)--(4,​3)--(4,​1)--(1,​1)}
 +          \fillarea{HotPink!30}{(1,​3)--(1,​7)--(4,​7)--(4,​6)--(2,​6)--(2,​3)--(1,​3)}
 +          \fillarea{GreenYellow}{(2,​3)--(2,​6)--(4,​6)--(4,​3)--(2,​3)}
 +          \fillarea{LightBlue}{(4,​1)--(7,​1)--(7,​5)--(6,​5)--(6,​2)--(4,​2)--(4,​1)}
 +          \fillarea{LightSalmon!50}{(4,​7)--(4,​4)--(5,​4)--(5,​6)--(6,​6--(6,​5)--(7,​5)--(7,​7)--(4,​7)}
 +          \fillarea{LightYellow}{(4,​2)--(4,​4)--(5,​4)--(5,​6)--(6,​6)--(6,​2)--(4,​2)}
 +        \end{puzzlebackground} ​
 +      \end{skyline}
 +      \hspace{1cm}
 +      \begin{skyline}[rows=6,​columns=6,​scale=.65]
 +        \skylineB{4,​2,​1,​3,​3,​2}
 +        \skylineL{3,​3,​4,​3,​2,​1}
 +        \skylineT{1,​2,​3,​3,​2,​4}
 +        \skylineR{4,​1,​2,​2,​2,​3}
 +        \setrow{6}{6,​3,​4,​1,​5,​2}
 +        \setrow{5}{5,​6,​2,​3,​1,​4}
 +        \setrow{4}{2,​1,​3,​6,​4,​5}
 +        \setrow{3}{1,​4,​5,​2,​6,​3}
 +        \setrow{2}{4,​2,​1,​5,​3,​6}
 +        \setrow{1}{3,​5,​6,​4,​2,​1}
 +        \begin{puzzlebackground}
 +          \fillarea{Wheat}{(1,​1)--(1,​3)--(4,​3)--(4,​1)--(1,​1)}
 +          \fillarea{HotPink!30}{(1,​3)--(1,​7)--(4,​7)--(4,​6)--(2,​6)--(2,​3)--(1,​3)}
 +          \fillarea{GreenYellow}{(2,​3)--(2,​6)--(4,​6)--(4,​3)--(2,​3)}
 +          \fillarea{LightBlue}{(4,​1)--(7,​1)--(7,​5)--(6,​5)--(6,​2)--(4,​2)--(4,​1)}
 +          \fillarea{LightSalmon!50}{(4,​7)--(4,​4)--(5,​4)--(5,​6)--(6,​6)--(6,​5)--(7,​5)--(7,​7)--(4,​7)}
 +          \fillarea{LightYellow}{(4,​2)--(4,​4)--(5,​4)--(5,​6)--(6,​6)--(6,​2)--(4,​2)}
 +        \end{puzzlebackground} ​
 +      \end{skyline}
 +    \end{center}
 +
 +Examples & Solutions
 +--------------------
 +
 +You can download application examples and their solutions from the
 +[project page](https://​bitbucket.org/​kleberj/​logicpuzzle/​). The puzzles are originally licensed under
 +[CC-BY-NC-SA](http://​creativecommons.org/​licenses/​by-nc-sa/​3.0/​).
 +
 +![qrcode](http://​imgur.com/​KAunnuS.png)
 +
 +</​markdown>​
skyline.txt · Last modified: 2015/09/06 09:52 (external edit)