Create a crossword puzzle

crossword(words, clues, r = 50, c = 50, method = c("optimal", "random"))

Arguments

words

a vector of words (character/vector)

clues

a vector a clues (character/vector)

r

number of rows (numeric/scalar)

c

number of columns (numeric/scalar)

method

generate puzzle using 'optimal' or 'random' word order, where the optimal order will place words with the most overlap first

Value

a 'crossword' object

Examples

# \donttest{
# Example 1 ----
words <- c("apple", "pear", "banana")
clues <- c("red fruit", "bartlett", "green then yellow")
x <- crossword(words, clues)
#> Found positions for 3/3 words.
plot(x, solution = TRUE)


# Example 2 ---
dat <-
dplyr::tribble(
  ~word,   ~clue,
  "dog",   "Bark. Bark. Bark.",
  "cat",   "Purrr",
  "horse", "Neighhhhh",
  "frog",  "Ribbit Ribbit",
  "cow",   "Moooooooo",
  "fox",   "Nee Nee Nee (What does the ____ say?)",
  "sheep", "Bleat",
  "snake", "Hissss",
  "duck",  "Quack",
  "bird",  "Chirp"
)
ex2 <- crossword(words = dat$word, clues = dat$clue, r = 40, c = 40)
#> Could not place the following words:
#> 
#> COW
#> BIRD
#> DUCK
#> DOG
#> SNAKE
#> CAT
#> FROG
#> Found positions for 3/10 words.
plot(ex2, solution = TRUE, clues = TRUE)

# }