Skip to content

bastistician/crossword

 
 

Repository files navigation

Generating Crosswords from Word Lists

Status

codecov

lines of R code: 429, lines of test code: 0

Development version

0.2.0 - 2017-08-09 / 19:05:23

Description

Generate crosswords from a list of words.

License

MIT + file LICENSE
Peter Meissner

Citation

citation("crossword")

BibTex for citing

toBibtex(citation("crossword"))

Installation

Stable version from CRAN:

install.packages("crossword")

Latest development version from Github:

devtools::install_github("petermeissner/crossword")

Usage

# load the library
library(crossword)

# create a new 4 by 4 crossword
cw <- Crossword$new(rows = 4, columns = 4)

# add a list of words
words <- c("back", "nasa", "kick", "nuk", "ic", "sic")
clues <- rep("-", length(words))

cw$add_words(
  words = words,
  clues = clues
)
## #BACK# / 5 / 1 / right / 
## 
## #NASA# / 1 / 3 / down / 
## 
## #KICK# / 1 / 5 / down / 
## 
## #NUK# / 2 / 2 / right / 
## 
## #IC# / 3 / 4 / down / 
## 
## #SIC# / 4 / 2 / right /
# use the default print method to have a look
cw
## . 1 2 3 4 5 6
## 1 # # # # # #
## 2 # # N U K #
## 3 # . A # I #
## 4 # # S I C #
## 5 # B A C K #
## 6 # # # # # #
# access to letters on the grid
cw$letters
##      [,1] [,2] [,3] [,4] [,5] [,6]
## [1,] "#"  "#"  "#"  "#"  "#"  "#" 
## [2,] "#"  "#"  "N"  "U"  "K"  "#" 
## [3,] "#"  "."  "A"  "#"  "I"  "#" 
## [4,] "#"  "#"  "S"  "I"  "C"  "#" 
## [5,] "#"  "B"  "A"  "C"  "K"  "#" 
## [6,] "#"  "#"  "#"  "#"  "#"  "#"

# access to words placed on the grid, their co-ordinates and so on
cw$words
## # A tibble: 6 x 6
##     row   col length direction  clue  word
##   <int> <int>  <int>     <chr> <chr> <chr>
## 1     5     1      4     right        BACK
## 2     1     3      4      down     -  NASA
## 3     1     5      4      down     -  KICK
## 4     2     2      3     right         NUK
## 5     3     4      2      down     -    IC
## 6     4     2      3     right         SIC

About

An R package to build crosswords

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HTML 96.0%
  • R 4.0%