Continue series of numbers by differencing. Add one more element and submit sum of these extrapolated values.
lapply(
txt
, FUN = \(i){
# i = txt[1]
l = strsplit(i, split = " ")[[1]] |>
as.integer() |>
list()
while (sum(abs(l[[1]])) > 0L){
l = c(list(diff(l[[1]])), l)
}
incr = integer(length(l))
incr[1] = 0
for (k in seq_along(l)){
l[[k]] = c(l[[k]], l[[k]][length(l[[k]])] + incr[k])
incr[k + 1] = l[[k]][length(l[[k]])]
}
l[[length(l)]][length(l[[length(l)]])]
}
) |>
unlist() |>
sum()
Add \(m\) successive cards where \(m\) is the number of matches in a card. Get the final number of cards.