Santa’s reindeer typically eat regular reindeer food, but they need a lot of magical energy to deliver presents on Christmas. For that, their favorite snack is a special type of star fruit that only grows deep in the jungle. The Elves have brought you on their annual expedition to the grove where the fruit grows.
To supply enough magical energy, the expedition needs to retrieve a minimum of fifty stars by December 25th. Although the Elves assure you that the grove has plenty of fruit, you decide to grab any fruit you see along the way, just in case.
Collect stars by solving puzzles. Two puzzles will be made available on each day in the Advent calendar; the second puzzle is unlocked when you complete the first. Each puzzle grants one star. Good luck!
The calories carried by the top three elves is 45,000. *
Day 2 * *
Rock Paper Scissors
Code
df2 <-tibble(strat =readLines('inputs/day2.txt')) |>separate(strat, into =c('them', 'us')) |>mutate(shape =case_when( us =='X'~1, us =='Y'~2, us =='Z'~3 ),outcome =case_when( them =='A'& us =='X'~3, them =='A'& us =='Y'~6, them =='A'& us =='Z'~0, them =='B'& us =='X'~0, them =='B'& us =='Y'~3, them =='B'& us =='Z'~6, them =='C'& us =='X'~6, them =='C'& us =='Y'~0, them =='C'& us =='Z'~3 ),score = shape + outcome ) stars <- stars +1
The total points for this strategy are 15. *
Code
df2_p2 <- df2 |>mutate(outcome = us,us =case_when( them =='A'& outcome =='X'~'Z', them =='A'& outcome =='Y'~'X', them =='A'& outcome =='Z'~'Y', them =='B'& outcome =='X'~'X', them =='B'& outcome =='Y'~'Y', them =='B'& outcome =='Z'~'Z', them =='C'& outcome =='X'~'Y', them =='C'& outcome =='Y'~'Z', them =='C'& outcome =='Z'~'X' ),shape_points =case_when( us =='X'~1, us =='Y'~2, us =='Z'~3 ),outcome_points =case_when( outcome =='X'~0, outcome =='Y'~3, outcome =='Z'~6 ),score = shape_points + outcome_points ) stars <- stars +1
The total points for the updated strategy are 12. *
inner <-crossing(x = (min(df_18$x) +1):(max(df_18$x) -1),y = (min(df_18$y) +1):(max(df_18$y) -1),z = (min(df_18$z) +1):(max(df_18$z) -1)) |>anti_join(df_18, by =c('x', 'y', 'z'))# need to check if there is a tunnel to these inner spots