Skip to content

Instantly share code, notes, and snippets.

@hadley
Last active February 18, 2023 19:58
Show Gist options
  • Save hadley/6db2217dff40cb56b524943492771227 to your computer and use it in GitHub Desktop.
Save hadley/6db2217dff40cb56b524943492771227 to your computer and use it in GitHub Desktop.
# 2022-01-06
# https://www.powerlanguage.co.uk/wordle/
library(stringr)
words <- words::words$word
words5 <- words[str_length(words) == 5]
# Find 5 letter containing most common letters
# (data from random googling)
common <- c("e", "a", "r", "i", "t", "n", "s", "l", "c", "u", "d", "p", "m", "h")
words5u %>%
str_subset(paste0("^[", paste0(common[1:5], collapse = ""), "]+$"))
# only irate is a common English word
words5 %>%
# "irate" 🟨🟨⬛🟨🟨
str_subset("[^i][^r].[^t][^e]") %>%
str_subset("a", negate = TRUE) %>%
str_subset("i") %>%
str_subset("r") %>%
str_subset("t") %>%
str_subset("e") %>%
# "merit" ⬛🟨🟨🟨🟨
str_subset("m", negate = TRUE) %>%
str_subset(".[^e][^r][^i][^t]")
@PythonCoderUnicorn
Copy link

that's pretty neat

Screen Shot 2022-01-06 at 5 38 22 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment