Package 'crosswordio'

Title: Read/Write Crosswords in PUZ Format
Description: Read and write crosswords in the standard PUZ format.
Authors: Mike Cheng [aut, cre, cph]
Maintainer: Mike Cheng <[email protected]>
License: MIT + file LICENSE
Version: 0.1.0
Built: 2026-05-25 07:35:39 UTC
Source: https://github.com/coolbutuseless/crosswordio

Help Index


Create a simple plot of a crossword

Description

Create a simple plot of a crossword

Usage

plot_puz(grid, across, down, add_position = TRUE, scale = 20, cex = 0.95)

Arguments

grid

character matrix containing the solution to the crossword. Non-letter grid squares (i.e. black squares) are denoted by the "." character.

across, down

cahracter vectors for the across and down clues in the order they appear when traversing the puzzle grid row-by-row. Note: Text should be utf8, convert if necessary e.g. iconv(..., to = "UTF-8")

add_position

Add position indices to the start of the text for the clues.

scale

overall scale applied to grid size and text size. Default: 20

cex

extra adjustment factor for text size of clues. Default: 0.95

Value

None.


Plot a crossword PUZ

Description

Plot a crossword PUZ

Usage

## S3 method for class 'puz'
plot(x, ...)

Arguments

x

PUZ object

...

passed to plot_puz()

Value

None


Read a crossword file in PUZ format

Description

Read a crossword file in PUZ format

Usage

read_puz(puz_file)

Arguments

puz_file

filename

Value

named list of crossword information

Examples

# This grid is the "Sator Square"
grid <- matrix(c(
"S", "A", "T", "O", "R",
"A", "R", "E", "P", "O",
"T", "E", "N", "E", "T",
"O", "P", "E", "R", "A",
"R", "O", "T", "A", "S"
), 5, 5, byrow = TRUE)

# In the Sator Square, all down and across words are identical
# and in Latin!
down <- across <- c(
  "sower, planter",
  "unknown word, perhaps a proper name of a non-Latin origin",
  "holds, keeps, comprehends, possesses, masters, preserves, sustains",
  "service, pains, labor; care, effort, attention",
  "wheels"
)

# Write crossword to a file in "puz" format
file <- tempfile()
write_puz(
  grid   = grid, 
  across = across, 
  down   = down, 
  title  = "SATOR SQUARE",
  file   = file
)

# Read the data back
read_puz(file)

Create a crossword in '.puz' format

Description

Create a crossword in '.puz' format

Usage

write_puz(
  grid,
  across,
  down,
  title = "",
  author = "",
  copyright = "",
  notes = "",
  file = NULL
)

Arguments

grid

character matrix containing the solution to the crossword. Non-letter grid squares (i.e. black squares) are denoted by the "." character.

across, down

cahracter vectors for the across and down clues in the order they appear when traversing the puzzle grid row-by-row. Note: Text should be utf8, convert if necessary e.g. iconv(..., to = "UTF-8")

title, author, copyright, notes

free text strings giving information about the crossword. Default: empty string. Note: Text should be utf8, convert if necessary e.g. iconv(..., to = "UTF-8")

file

filename for output. Default: NULL means to return the raw vectors.

Value

Returns raw vector of data if no filename is set, otherwise returns nothing.

Examples

# This grid is the "Sator Square"
grid <- matrix(c(
"S", "A", "T", "O", "R",
"A", "R", "E", "P", "O",
"T", "E", "N", "E", "T",
"O", "P", "E", "R", "A",
"R", "O", "T", "A", "S"
), 5, 5, byrow = TRUE)

# In the Sator Square, all down and across words are identical
# and in Latin!
down <- across <- c(
  "sower, planter",
  "unknown word, perhaps a proper name of a non-Latin origin",
  "holds, keeps, comprehends, possesses, masters, preserves, sustains",
  "service, pains, labor; care, effort, attention",
  "wheels"
)

# Write crossword to a file in "puz" format
file <- tempfile()
write_puz(
  grid   = grid, 
  across = across, 
  down   = down, 
  title  = "SATOR SQUARE",
  file   = file
)

# Read the data back
read_puz(file)