06: Signals and Noise

library(mistlecode)
To install `mistlecode` yourself, run `devtools::install_github('guslipkin/mistlecode')`.

 Also loading:  cipheR data.table dplyr purrr slider stringr tidyverse glue
dt <-
  readLines("input.txt") |>
  str_split("") |>
  map(~ data.frame(t(.x))) |>
  bind_rows()

Part 1

omg. This is gonna be so easy.

Edit: it was!

dt |>
  map_chr(\(x) {
    x |>
      table() |>
      sort(decreasing = TRUE) |>
      head(1) |>
      names()
  }) |>
  paste0(collapse = "")
[1] "bjosfbce"

Part 2

Classic. Just drop decreasing = TRUE.

dt |>
  map_chr(\(x) {
    x |>
      table() |>
      sort() |>
      head(1) |>
      names()
  }) |>
  paste0(collapse = "")
[1] "veqfxzfx"