-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
52 lines (40 loc) · 1.57 KB
/
README.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
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
```
```{r badges, echo = FALSE}
badge_stars <- function(color = "green", url = NULL, cookie = Sys.getenv("ADVENT_COOKIE_2024")) {
req <- httr::GET(
glue::glue('https://adventofcode.com/'),
httr::add_headers(
.headers = c(
"user-agent" = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36",
"cookie" = paste0("session=", cookie)
)
)
)
parsed <- xml2::read_html(req)
stars <- rvest::html_node(parsed, ".user")
star_text <- rvest::html_text(stars)
badge <- paste0("![](https://img.shields.io/badge/", "2024 star count", "-", star_text, "-", color, ".svg)")
if (is.null(url))
return(badge)
paste0("[", badge, "](", url, ")")
}
```
# Advent of Code
<!-- badges: start -->
`r badge_stars()`
<!-- badges: end -->
This repo contains all of my Advent of Code solutions using R. I'm using this to practice programming and problem-based solutions, but it's mostly for a little holiday fun. I'm also using a custom repo badge that scrapes a user's Advent of Code star count and displays it as a badge.
## Solutions so far
### [2024](R/2024) | [2023](R/2023) | [2022](R/2022) | [2021](R/2021) | [2020](R/2020)
| Day | Puzzle | Solution | Data |
| :---: | :---: | :---: | :---: |
| 1 | [Historian Hysteria](https://adventofcode.com/2024/day/1) | [R](R/2024/) | [Puzzle input](data/2024/)