https://adventofcode.com/2018/day/1
library(data.table)
dt <- fread("input.txt")
head(dt)
V1
1: -14
2: 15
3: 9
4: 19
5: 18
6: 14
Part 2
breakFlag <- FALSE
re_pete <- 1
while (!breakFlag) {
vec <- cumsum(rep(dt$V1, re_pete))
twice <- vec[duplicated(vec)]
if (length(twice >= 1)) {
print(twice[1])
breakFlag <- TRUE
} else {
re_pete <- re_pete + 1
}
}