Skip to content

Instantly share code, notes, and snippets.

@cataska
Last active January 26, 2022 14:10
Show Gist options
  • Save cataska/56f0f98102a9fbe3f60320e35f0c0550 to your computer and use it in GitHub Desktop.
Save cataska/56f0f98102a9fbe3f60320e35f0c0550 to your computer and use it in GitHub Desktop.
(defconstant +words-filename+ "words.txt")
(defun date-to-ms (year month day)
(* (encode-universal-time 0 0 0 day month year) 1000))
(defvar *base-date* (date-to-ms 2021 6 19))
(defvar *day-in-ms* 86400000)
(defun parse-words-input (pathname)
(uiop:read-file-lines pathname))
(defun wordle (year month day)
(let* ((words (parse-words-input +words-filename+))
(words-length (list-length words))
(date-diff (floor (- (date-to-ms year month day) *base-date*) *day-in-ms*)))
(nth (rem date-diff words-length) words)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment