<- function (df) {
helper1_20231201 <- df %>%
df2 mutate(digit_locs = X1 %>%
::str_locate_all("[1-9]") %>%
stringrmap(~.x[c(1, nrow(.x)), "start"])
%>%
) rowwise() %>%
mutate(X2 = as.numeric(paste0(
::str_sub(X1, start = digit_locs[1], end = digit_locs[1]),
stringr::str_sub(X1, start = digit_locs[2], end = digit_locs[2])
stringr%>%
))) ungroup()
return(df2)
}<- readr::read_delim("input.txt",
df1 delim = "|",
col_names = FALSE)
Day 1 ⋆
Puzzle
Solution
Preprocessing
Part 1
<- df1 %>%
answer1 helper1_20231201() %>%
summarise(sum(X2)) %>%
pull()
print(answer1)
[1] 54390
Part 2
I haven’t solved this part yet!