04: The Ideal Stocking Stuffer

library(tidyverse)
── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
✔ ggplot2 3.4.0      ✔ purrr   0.3.5 
✔ tibble  3.1.8      ✔ dplyr   1.0.10
✔ tidyr   1.2.1      ✔ stringr 1.4.1 
✔ readr   2.1.3      ✔ forcats 0.5.2 
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
library(stringr)
library(digest)
dt <- "bgvyzdsv"

Part 1

i <- 0
while(substr(digest(paste0(dt, i), algo = "md5", serialize = FALSE), 1, 5) != "00000")
  i <- i + 1
digest(paste0(dt, i), algo = "md5", serialize = FALSE)
[1] "000004b30d481662b9cb0c105f6549b2"
i
[1] 254575

Part 2

i <- 0
while(substr(digest(paste0(dt, i), algo = "md5", serialize = FALSE), 1, 6) != "000000")
  i <- i + 1
digest(paste0(dt, i), algo = "md5", serialize = FALSE)
[1] "000000b1b64bf5eb55aad89986126953"
i
[1] 1038736