-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.Rmd
67 lines (52 loc) · 1.56 KB
/
index.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
---
title: "R Advent Of Code"
description: |
Emil Hvitfeldt's solutions
site: distill::distill_website
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
# Learn more about creating websites with Distill at:
# https://rstudio.github.io/distill/website.html
# Learn more about publishing to GitHub Pages at:
# https://rstudio.github.io/distill/publish_website.html#github-pages
```
This website is created using the [emilhvitfeldt/rstats-adventofcode](https://github.com/emilhvitfeldt/rstats-adventofcode) repository. I try to save all my solution in one place here.
I don't have any rules I follow. I will end up doing most solutions using base R because of the nature of the problems. I will be using both `purrr` and `stringr` when the need comes up, I don't hate myself. I'm here to write code and have fun doing it.
# Completion
```{css}
tbody {
color: #ffff66;
}
thead {
color: #cccccc;
}
```
```{r}
#| message: false
library(tidyverse)
get_solutions <- function(year) {
res <- glue::glue("{year}/") |>
fs::dir_ls() |>
stringr::str_subset("input", negate = TRUE) |>
basename() |>
stringr::str_sub(1, 2) |>
as.numeric() |>
factor(levels = 1:25)
tibble(Day = res, year = year)
}
years <- 2015:2024
years %>%
map_dfr(get_solutions) %>%
mutate(year = factor(year, years)) %>%
count(year, Day, .drop = FALSE) %>%
group_by(year) %>%
mutate(n = case_when(
Day != 25 ~ n,
sum(n) == 49 ~ 2L,
TRUE ~ n
)) %>%
mutate( n = strrep("*", n)) %>%
pivot_wider(names_from = year, values_from = n) %>%
knitr::kable()
```