Riddler: Spelling Bee Honeycomb

Simulation with matrixes

Notable topics: Simulation with matrixes

Recorded on: 2020-01-05

Timestamps by: Alex Cookson

## Screencast

## Timestamps

Using read_lines function to import a plain text file (.txt)

Using str_detect function to filter out words that do not contain the letter "g"

Using str_split function to get a list of a word's individual letters

Using setdiff function to find words with invalid letters (letters that are not in the puzzle honeycomb) -- also needs map function (at 4:35)

Changing existing code to make a function that will calculate scores for letter combinations

Noticing the rule about bonus points for pangrams and using n_distinct function to determine if a word gets those points

Using map function to eliminate duplicate letters from each word's list of component letters

Using acast function from reshape2 package to create a matrix of words by letters

Using a the words/letters matrix to find valid words for a given letter combination

Using the matrix multiplication operator %*% to find the number of "forbidden" letters for each word

Using microbenchmark function from microbenchmark package to test how long it takes to run a function

Using combn function to get the actual combinations of 6 letters (not just the count)

Using map function to get scores for different combinations of letters created above

Using which.max function to find the position of the max value in a vector

Using t function to transpose a matrix

Summary of screencast