04: The Ideal Stocking Stuffer

library(tidyverse)
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