|
@@ -0,0 +1,16 @@
|
|
1
|
+library(stringr)
|
|
2
|
+library(dplyr)
|
|
3
|
+input <- readLines("input6.txt")
|
|
4
|
+ig <- paste0(input, collapse = "\n") %>% str_split("\n\n") %>% unlist()
|
|
5
|
+
|
|
6
|
+igt <- ig %>% str_replace_all("\n", "")
|
|
7
|
+qans <- sapply(letters, function(l) {str_count(igt, l) > 0})
|
|
8
|
+sum(rowSums(qans))
|
|
9
|
+sum(qans) #or actually...
|
|
10
|
+
|
|
11
|
+tans <- sapply(letters, function(l) {str_count(igt, l)})
|
|
12
|
+
|
|
13
|
+numpg <- str_count(ig, "\n") + 1
|
|
14
|
+
|
|
15
|
+qtans <- apply(tans, 2, function(x) {x == numpg})
|
|
16
|
+sum(qtans)
|