nonogram: nonogram

View source: R/nonogram.R

nonogramR Documentation

nonogram

Description

Constructor function to create an instance of the S3 class nonogram.

Usage

nonogram(rows, columns)

Arguments

rows

A list whose elements are numeric vectors indicating the pattern within each row.

columns

A list whose elements are numeric vectors indicating the pattern within each column.

Details

Each element of the rows and columns arguments should be a numeric vector giving the pattern of runs for that row or column. For example, c(2, 1) indicates a row or column with a run of length 2 followed by a run of length 1, reading from left to right for a row and reading from top to bottom for a column. The first element of the list given to rows will correspond to the top row of the nonogram.The first element of the list given to columns will correspond to the leftmost column of the nonogram.

Value

An object of S3 class nonogram, with the following elements:

  • rows: The list of row patterns used to construct the nonogram.

  • columns: The list of column patterns used to construct the nonogram.

  • nrows: The number of rows.

  • ncolumns: The number of columns.

  • dims: A vector of length 2 indicating the number of rows an columns.

  • solved: Logical flag indicating whether the object contains a solution.

  • row_solution: List of row solutions.

  • column_solution: List of column solutions.

Examples

nonogram(
    rows = list(
      c(1), c(1), c(2, 1), c(2, 1), c(3, 2), c(4, 3), c(5, 4),  c(1),  c(8),  c(6)
      ),
    columns = list(
      c(1), c(2, 1),  c(3, 2),  c(5, 2),  c(7, 2), c(3),  c(5, 2),  c(3, 2),  c(2, 1),  c(1)
      )
   )

hrj21/nonogram documentation built on April 6, 2024, 1:14 a.m.