Skip to content

Commit

Permalink
adds timing to each days file
Browse files Browse the repository at this point in the history
  • Loading branch information
tomjemmett committed Jan 7, 2021
1 parent d9a713d commit cf585fc
Show file tree
Hide file tree
Showing 25 changed files with 148 additions and 1 deletion.
6 changes: 6 additions & 0 deletions day_01.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
knitr::opts_chunk$set(echo = TRUE)
options(crayon.enabled = NULL)
library(tidyverse)
START_TIME <- Sys.time()
```

This is my attempt to solve [Day 1](https://adventofcode.com/2020/day/1).
Expand Down Expand Up @@ -247,3 +249,7 @@ def part_2_py(input_values, target):
bench::mark(part_2_improved(actual, 2020),
py$part_2_py(actual, 2020))
```

---

*Elapsed Time: `r round(Sys.time() - START_TIME, 3)`s*
6 changes: 6 additions & 0 deletions day_02.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
knitr::opts_chunk$set(echo = TRUE)
options(crayon.enabled = NULL)
library(tidyverse)
START_TIME <- Sys.time()
```

This is my attempt to solve [Day 2](https://adventofcode.com/2020/day/2).
Expand Down Expand Up @@ -126,3 +128,7 @@ This matches the example, so we can now solve part 2.
```{r part 2 solution}
length(part_2_valid_passwords(actual))
```

---

*Elapsed Time: `r round(Sys.time() - START_TIME, 3)`s*
6 changes: 6 additions & 0 deletions day_03.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
knitr::opts_chunk$set(echo = TRUE)
options(crayon.enabled = NULL)
library(tidyverse)
START_TIME <- Sys.time()
```

This is my attempt to solve [Day 3](https://adventofcode.com/2020/day/3).
Expand Down Expand Up @@ -149,3 +151,7 @@ The other combinations would be going just 1 down at each step, and then all of
that the greatest common divisor of right and down is 1. This would give us all of the movements that don't violate the
constraint above of a non-unique movement. For instance, 6 right, 2 down has a greatest common divisor of 2, and this
combination is the same as 3 right, 1 down.

---

*Elapsed Time: `r round(Sys.time() - START_TIME, 3)`s*
6 changes: 6 additions & 0 deletions day_04.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
knitr::opts_chunk$set(echo = TRUE)
options(crayon.enabled = NULL)
library(tidyverse)
START_TIME <- Sys.time()
```

This is my attempt to solve [Day 4](https://adventofcode.com/2020/day/4).
Expand Down Expand Up @@ -191,3 +193,7 @@ actual %>%
map_lgl(compose(all, flatten_lgl)) %>%
sum()
```

---

*Elapsed Time: `r round(Sys.time() - START_TIME, 3)`s*
6 changes: 6 additions & 0 deletions day_05.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
knitr::opts_chunk$set(echo = TRUE)
options(crayon.enabled = NULL)
library(tidyverse)
START_TIME <- Sys.time()
```

This is my attempt to solve [Day 5](https://adventofcode.com/2020/day/5).
Expand Down Expand Up @@ -110,3 +112,7 @@ triangle_number <- function(n) 0.5 * n * (n + 1)
triangle_number(max(seats)) - triangle_number(min(seats) - 1) - sum(seats)
```

---

*Elapsed Time: `r round(Sys.time() - START_TIME, 3)`s*
6 changes: 6 additions & 0 deletions day_06.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
knitr::opts_chunk$set(echo = TRUE)
options(crayon.enabled = NULL)
library(tidyverse)
START_TIME <- Sys.time()
```

This is my attempt to solve [Day 6](https://adventofcode.com/2020/day/6).
Expand Down Expand Up @@ -112,3 +114,7 @@ We can now check that this new function works as expected:
extra(actual, union) == part_1(actual)
extra(actual, intersect) == part_2(actual)
```

---

*Elapsed Time: `r round(Sys.time() - START_TIME, 3)`s*
6 changes: 6 additions & 0 deletions day_07.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ library(tidyverse)
library(igraph)
library(ggraph)
library(unglue)
START_TIME <- Sys.time()
```

This is my attempt to solve [Day 7](https://adventofcode.com/2020/day/7).
Expand Down Expand Up @@ -154,3 +156,7 @@ part_2_alt(sample_g, "shiny gold", 1) - 1 == part_2(sample_g)
```{r extra part 2 alt actual test}
part_2_alt(actual_g, "shiny gold", 1) - 1 == part_2(actual_g)
```

---

*Elapsed Time: `r round(Sys.time() - START_TIME, 3)`s*
6 changes: 6 additions & 0 deletions day_08.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ options(crayon.enabled = NULL)
library(tidyverse)
library(R6)
library(unglue)
START_TIME <- Sys.time()
```

This is my attempt to solve [Day 8](https://adventofcode.com/2020/day/8).
Expand Down Expand Up @@ -321,3 +323,7 @@ Computer <- R6Class(
)
)
```

---

*Elapsed Time: `r round(Sys.time() - START_TIME, 3)`s*
6 changes: 6 additions & 0 deletions day_09.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
knitr::opts_chunk$set(echo = TRUE)
options(crayon.enabled = NULL)
library(tidyverse)
START_TIME <- Sys.time()
```

This is my attempt to solve [Day 9](https://adventofcode.com/2020/day/9).
Expand Down Expand Up @@ -89,3 +91,7 @@ And run on the actual input:
```{r part 2 sample actual}
part_2(actual, pa1)
```

---

*Elapsed Time: `r round(Sys.time() - START_TIME, 3)`s*
6 changes: 6 additions & 0 deletions day_10.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
knitr::opts_chunk$set(echo = TRUE)
options(crayon.enabled = NULL)
library(tidyverse)
START_TIME <- Sys.time()
```

This is my attempt to solve [Day 10](https://adventofcode.com/2020/day/10).
Expand Down Expand Up @@ -86,3 +88,7 @@ notation by setting the `scipen` option.
options(scipen = 999)
part_2(actual)
```

---

*Elapsed Time: `r round(Sys.time() - START_TIME, 3)`s*
6 changes: 6 additions & 0 deletions day_11.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
knitr::opts_chunk$set(echo = TRUE)
options(crayon.enabled = NULL)
library(tidyverse)
START_TIME <- Sys.time()
```

This is my attempt to solve [Day 11](https://adventofcode.com/2020/day/11).
Expand Down Expand Up @@ -386,3 +388,7 @@ solve(pactual, part_one, 4)
solve(psample, part_two, 5)
solve(pactual, part_two, 5)
```

---

*Elapsed Time: `r round(Sys.time() - START_TIME, 3)`s*
6 changes: 6 additions & 0 deletions day_12.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
knitr::opts_chunk$set(echo = TRUE)
options(crayon.enabled = NULL)
library(tidyverse)
START_TIME <- Sys.time()
```

This is my attempt to solve [Day 12](https://adventofcode.com/2020/day/12).
Expand Down Expand Up @@ -196,3 +198,7 @@ We can now run with the actual data:
```{r part 2 actual}
solve(iactual)
```

---

*Elapsed Time: `r round(Sys.time() - START_TIME, 3)`s*
6 changes: 6 additions & 0 deletions day_13.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
knitr::opts_chunk$set(echo = TRUE)
options(crayon.enabled = NULL)
library(tidyverse)
START_TIME <- Sys.time()
```

This is my attempt to solve [Day 13](https://adventofcode.com/2020/day/13).
Expand Down Expand Up @@ -98,3 +100,7 @@ the answer as an integer.
options(scipen = 999)
part_2(actual)
```

---

*Elapsed Time: `r round(Sys.time() - START_TIME, 3)`s*
4 changes: 4 additions & 0 deletions day_14.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ options(crayon.enabled = NULL, # for when rendering on github actions
scipen = 999) # make sure we never print in scientific notation
library(tidyverse)
library(unglue)
START_TIME <- Sys.time()
```

This is my attempt to solve [Day 14](https://adventofcode.com/2020/day/14).
Expand Down Expand Up @@ -174,4 +176,6 @@ part_2(sample_2) == 208
part_2(actual)
```

---

*Elapsed Time: `r round(Sys.time() - START_TIME, 3)`s*
6 changes: 6 additions & 0 deletions day_15.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ knitr::opts_chunk$set(echo = TRUE)
options(crayon.enabled = NULL, # for when rendering on github actions
scipen = 999) # make sure we never print in scientific notation
library(tidyverse)
START_TIME <- Sys.time()
```

This is my attempt to solve [Day 15](https://adventofcode.com/2020/day/15).
Expand Down Expand Up @@ -71,3 +73,7 @@ We don't need to change anything for part 2, other than the number of turns.
```{r part 2}
solve(actual, 30000000)
```

---

*Elapsed Time: `r round(Sys.time() - START_TIME, 3)`s*
8 changes: 7 additions & 1 deletion day_16.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ options(crayon.enabled = NULL, # for when rendering on github actions
scipen = 999) # make sure we never print in scientific notation
library(tidyverse)
library(unglue)
START_TIME <- Sys.time()
```

This is my attempt to solve [Day 16](https://adventofcode.com/2020/day/16).
Expand Down Expand Up @@ -163,11 +165,15 @@ part_2(psample_2)

And now we can solve the actual problem. Find the fields and their positions, the apply those positions to `my_ticket`:

```{r}
```{r part 2 actual}
ps <- pactual %>%
part_2() %>%
filter(str_detect(field, "^departure")) %>%
pull(pos)
prod(pactual$my_ticket[ps])
```

---

*Elapsed Time: `r round(Sys.time() - START_TIME, 3)`s*
6 changes: 6 additions & 0 deletions day_17.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ options(crayon.enabled = NULL, # for when rendering on github actions
scipen = 999) # make sure we never print in scientific notation
library(tidyverse)
library(unglue)
START_TIME <- Sys.time()
```

This is my attempt to solve [Day 17](https://adventofcode.com/2020/day/17).
Expand Down Expand Up @@ -199,3 +201,7 @@ actual %>%
run_n_iterations_4d(6) %>%
sum()
```

---

*Elapsed Time: `r round(Sys.time() - START_TIME, 3)`s*
6 changes: 6 additions & 0 deletions day_18.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ options(crayon.enabled = NULL, # for when rendering on github actions
library(tidyverse)
library(unglue)
library(R6)
START_TIME <- Sys.time()
```

This is my attempt to solve [Day 18](https://adventofcode.com/2020/day/18).
Expand Down Expand Up @@ -195,3 +197,7 @@ And we can run the function on the actual data.
```{r part 2 actual}
sum(part_2(actual))
```

---

*Elapsed Time: `r round(Sys.time() - START_TIME, 3)`s*
6 changes: 6 additions & 0 deletions day_19.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ options(crayon.enabled = NULL, # for when rendering on github actions
scipen = 999) # make sure we never print in scientific notation
library(tidyverse)
library(unglue)
START_TIME <- Sys.time()
```

This is my attempt to solve [Day 19](https://adventofcode.com/2020/day/19).
Expand Down Expand Up @@ -172,3 +174,7 @@ part_2(part_2_sample)
```{r part 2 actual}
part_2(actual)
```

---

*Elapsed Time: `r round(Sys.time() - START_TIME, 3)`s*
6 changes: 6 additions & 0 deletions day_20.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ knitr::opts_chunk$set(echo = TRUE)
options(crayon.enabled = NULL, # for when rendering on github actions
scipen = 999) # make sure we never print in scientific notation
library(tidyverse)
START_TIME <- Sys.time()
```

This is my attempt to solve [Day 20](https://adventofcode.com/2020/day/20).
Expand Down Expand Up @@ -371,3 +373,7 @@ part_2(actual)

This felt rather tedious and procedural, perhaps there is a neater solution. Improvements could be made to my code by
extracting some of the repeated logic into functions.

---

*Elapsed Time: `r round(Sys.time() - START_TIME, 3)`s*
6 changes: 6 additions & 0 deletions day_21.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ options(crayon.enabled = NULL, # for when rendering on github actions
scipen = 999) # make sure we never print in scientific notation
library(tidyverse)
library(igraph)
START_TIME <- Sys.time()
```

This is my attempt to solve [Day 21](https://adventofcode.com/2020/day/21).
Expand Down Expand Up @@ -116,3 +118,7 @@ And we can run our function on the actual data:
```{r part 2 actual}
part_2(actual)
```

---

*Elapsed Time: `r round(Sys.time() - START_TIME, 3)`s*
6 changes: 6 additions & 0 deletions day_22.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ knitr::opts_chunk$set(echo = TRUE)
options(crayon.enabled = NULL, # for when rendering on github actions
scipen = 999) # make sure we never print in scientific notation
library(tidyverse)
START_TIME <- Sys.time()
```

This is my attempt to solve [Day 22](https://adventofcode.com/2020/day/22).
Expand Down Expand Up @@ -175,3 +177,7 @@ And we can run this function on the actual data:
```{r part 2 actual}
part_2(actual)
```

---

*Elapsed Time: `r round(Sys.time() - START_TIME, 3)`s*
6 changes: 6 additions & 0 deletions day_23.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ knitr::opts_chunk$set(echo = TRUE)
options(crayon.enabled = NULL, # for when rendering on github actions
scipen = 999) # make sure we never print in scientific notation
library(tidyverse)
START_TIME <- Sys.time()
```

This is my attempt to solve [Day 23](https://adventofcode.com/2020/day/23).
Expand Down Expand Up @@ -129,3 +131,7 @@ And we can run the function on our actual data:
```{r part 2 actual}
part_2(actual)
```

---

*Elapsed Time: `r round(Sys.time() - START_TIME, 3)`s*
Loading

0 comments on commit cf585fc

Please sign in to comment.