2019-01: The Tyranny of the Rocket Equation

dt <- as.numeric(readLines("input.txt"))

Part 1

sum(floor(dt / 3) - 2)
[1] 3512133

Part 2

x <- 1
total <- 0
sapply(dt, function(x) {
  total <- 0
  val <- x
  while (floor(val / 3) - 2 >= 0) {
    val <- floor(val / 3) - 2
    total <- total + val
  }
  return(total)
}) |>
  sum()
[1] 5265294