Browse Source

Start on 2018 for funsies

Petra Lamborn 1 year ago
parent
commit
ad2907b18b
4 changed files with 1275 additions and 0 deletions
  1. 8
    0
      2018/1.R
  2. 18
    0
      2018/2.R
  3. 999
    0
      2018/input1.txt
  4. 250
    0
      2018/input2.txt

+ 8
- 0
2018/1.R View File

@@ -0,0 +1,8 @@
1
+input <- as.numeric(readLines("input1.txt"))
2
+
3
+sum(input)
4
+
5
+# I should have worked out how to automate finding this, but I didn't want to do a loop
6
+ic <- cumsum(rep(input, length.out = 139435))
7
+
8
+table(table(ic))

+ 18
- 0
2018/2.R View File

@@ -0,0 +1,18 @@
1
+library(stringr)
2
+input <- readLines("input2.txt")
3
+
4
+itab <- sapply(letters, function(l) { str_count(input, l)})
5
+w2 <- apply(itab, 1, function(r) {2 %in% r})
6
+w3 <- apply(itab, 1, function(r) {3 %in% r})
7
+sum(w2) * sum(w3)
8
+
9
+am <- sapply(input, function(x) {
10
+           l <- nchar(x)
11
+           sapply(1:l, function(i) {
12
+                paste0(str_sub(x, 0, i-1), ".", str_sub(x, i+1))
13
+           })
14
+       })
15
+
16
+ctab <- table(as.character(am))
17
+
18
+which.max(ctab)

+ 999
- 0
2018/input1.txt
File diff suppressed because it is too large
View File


+ 250
- 0
2018/input2.txt View File

@@ -0,0 +1,250 @@
1
+cnjxpritdzhubeseewfmqagkul
2
+cwyxpgitdzhvbosyewfmqagkul
3
+cnfxpritdzhebosywwfmqagkul
4
+cnjxpritdzgvbosyawfiqagkul
5
+cnkxpritdzhvbosyewfmgagkuh
6
+gnjxprhtdzhebosyewfmqagkul
7
+cnjxpriedzevbosyewfjqagkul
8
+cnjxpritdzhpyosyewfsqagkul
9
+cnjxprltdzhvbosyewfmhagkzl
10
+cnjxfritdjhvbosyewfmiagkul
11
+xnjxpritdzhvbosyewfmqagkgn
12
+cnjxpritdzmvzosyewfhqagkul
13
+cljxxritdzhvbosyewfmragkul
14
+cnjxjritdzhvbovyewfmvagkul
15
+cnjxprdtdzhpbosyewvmqagkul
16
+cojxprdtdzhzbosyewfmqagkul
17
+cnjxpritgzhvfgsyewfmqagkul
18
+knjxprptdzhvbosyecfmqagkul
19
+cnjxpritdzhvbvsyeyfmqagkuc
20
+cnjxpritdzhvbosvewfmoagjul
21
+cnjxpritdzhvbosyfwfmbagkjl
22
+cnjxpjitazhvbosfewfmqagkul
23
+cnjtpfitdzhvbosyewfmiagkul
24
+ckjxpritdzhvbysyewfmqagoul
25
+cnjxvritdzhvbfsyewfmqalkul
26
+cnjipqitdzhvbosyewfeqagkul
27
+cnjhpritdzhvbosyewymqjgkul
28
+cnjxprrtdzhvbosyewfmlkgkul
29
+cnjxnritdzhvbopyewfmqaskul
30
+cxjxpritdzhvtosyewjmqagkul
31
+cnjxpritdzhvbjsyewfrqagkwl
32
+cnjxhritdzhubosyewfmqagvul
33
+cnjxpritdzhvbosyyyfmeagkul
34
+cnjxkritdzhvaoeyewfmqagkul
35
+cnjxpritdzhvtotyewfmqazkul
36
+cnjxoriadzhvbosyewfmqcgkul
37
+cnjxpritdzhcbosyewfmkapkul
38
+fnjxprtddzhvbosyewfmqagkul
39
+cnjxmvitdzhvbosyewfmqagrul
40
+cnjxpyitdzhibosyewfmqagktl
41
+cyjxprxtdzhvbosyewbmqagkul
42
+onjxpditdzhvbosyeofmqagkul
43
+cnjxprixdzhvbosuewftqagkul
44
+cnjxpritdrhvaosyewymqagkul
45
+cnjxpritdzhhbokyewfvqagkul
46
+cnjxpritczhvbosyewfmqwgxul
47
+cnjxpribdzqvbnsyewfmqagkul
48
+ynpxpritdzhvbvsyewfmqagkul
49
+cnjxprirdzhvboerewfmqagkul
50
+cnjxpritdxhvbosyewfmgavkul
51
+cnwxprntdzhvbosyewfmqagkuk
52
+cnjxpritzzhvbosyewfmcagktl
53
+bbjxpritdzhvbosyetfmqagkul
54
+cnjxpbitdzhvbosyewrmqagkui
55
+cnjxwrildzcvbosyewfmqagkul
56
+cnqxpoitdzhvbosnewfmqagkul
57
+cnzxpritdzhvbosyewfmqazkfl
58
+cnjxpriddzhvoosyewfmhagkul
59
+znjxpritdzhvbosjewfmqagkur
60
+cnjxpritdzhvbosyewcmfagkuk
61
+cnjxpritdzhvbomyywnmqagkul
62
+cnjxpgitjzhvbosyejfmqagkul
63
+cnjxpkitdzjvbosyewfmqcgkul
64
+cnjxpritduhvbosyewfmqfkkul
65
+cnfxpritdzhvbgsyewfmqwgkul
66
+cnjxpritdzhvbosywufmqaskul
67
+cnjxprittzhvboryswfmqagkul
68
+cndxpritpzrvbosyewfmqagkul
69
+cnjxpritdzhvbosyewfwqazkum
70
+cccxprmtdzhvbosyewfmqagkul
71
+cnjxpzitdzhvlbsyewfmqagkul
72
+cnjxdrigdzhvbosyewfmqagsul
73
+fhjxpritdzhvbosyewfmqagkcl
74
+cnjxpritdzhvdosyewffqagaul
75
+cnjxprikdztvbosyekfmqagkul
76
+cnjxpritdzhvbohiewfmqagkue
77
+cnjxpritdzhvbowyetfmqegkul
78
+cnuxpritdzhvbosyewmmqapkul
79
+qnjxpritdzhvbosyewfmjakkul
80
+cnjxpritdzlvbosyewiaqagkul
81
+cnjxpritdzhpoosyewfmvagkul
82
+cdjxpritdzhvboryewfbqagkul
83
+cnjxppitxzhvbosyewymqagkul
84
+cnjxpywtdzhvboiyewfmqagkul
85
+cnjxpritdzpvbosyezfmqaqkul
86
+cnjppritdghvbosyewfdqagkul
87
+cmjxpritdzhvbosvewfmqagkup
88
+cnjxoritdzhvbosylffmqagkul
89
+cnjxfritdzhvbojyewfmqagkvl
90
+cnjxpritdzhvbozyewgmqlgkul
91
+cnjxlritdzhvbosyewfmqalkug
92
+cnyxprittzhvbosyewfmsagkul
93
+cnjxprytdzcvdosyewfmqagkul
94
+ctjxpritdzhvbosyedfmqagkil
95
+cnjxpvitdzhrbosyewfmqaekul
96
+cnyxyritdzhvbospewfmqagkul
97
+cnjxoritwzhvbosyewrmqhgkul
98
+cnjxpritdzhjbosyqwsmqagkul
99
+cnjzprindzhvbosyewfmqabkul
100
+cnjspritdzhvbosysffmqagkul
101
+cnxxpritdzhvbosyelfmqageul
102
+bnjhpritdzhvbosyewfmzagkul
103
+cnjxbhitdzhdbosyewfmqagkul
104
+cnjxprktdzmvbosyewfmqagkuj
105
+cnjxprixdzhvbqsyewfmqmgkul
106
+cnjxpkitdzhvbosyewfmqagbum
107
+cnjhpritdzhxbosyewfmqagjul
108
+cnjxpritdzzvbosyewuqqagkul
109
+cnjxprhtdzhvuopyewfmqagkul
110
+cnjxpritdzhjqosyewfmqagkgl
111
+cnzxpritdzhvbosyejfmuagkul
112
+cnvxpritoohvbosyewfmqagkul
113
+cnjxpmitdzwvbosyemfmqagkul
114
+cnjoprittzzvbosyewfmqagkul
115
+cnjxpgitdzhvbosytwfmqsgkul
116
+cnjxprrtdehvbosyewfnqagkul
117
+onjxpjitdzgvbosyewfmqagkul
118
+cnjxpmitdzhvbopaewfmqagkul
119
+cnjxpritqzhvbosoewfrqagkul
120
+cnjxpnitdzhvbosyewfmqagkjy
121
+cnsxpritdzhvbosyewfmqjykul
122
+cnjxpriidzhvbosyewfmqxgkut
123
+cnjxpyitdzhnbosyewfgqagkul
124
+cnjxpritdzhbboyyewfmqagsul
125
+cnjxpeitdzsvbosyewfmqabkul
126
+cnjxpritdzhzvosyewfmragkul
127
+cnjrpritdzhmbosyewfmqrgkul
128
+cnjxpritdzhmbosyenfmqaglul
129
+cnjxqrntdzhvboswewfmqagkul
130
+cnjxprdtpzhvbosyewfmqagkcl
131
+cnjxpritdzhvsdsyewfmqagkur
132
+cnjxpritdzhvvosyewumqhgkul
133
+cnzxpritdznvhosyewfmqagkul
134
+ynjypritdzhvbosyewfmqagkuz
135
+cnjxpnitdzhvbocyezfmqagkul
136
+vnjxpritdzhvbfsyewfmjagkul
137
+cnjfpritdzhvbosyewfmqagkzu
138
+cnjxpritdzhbbosyewfmlegkul
139
+cnjxpnitdzhvbosyesfmbagkul
140
+cnjxpritezwvbosyewfmqagkgl
141
+cujxpritdzhqbosyawfmqagkul
142
+cnjxprindzhrbosyerfmqagkul
143
+cntxpritdzhvbosyewfmqauxul
144
+cnjxpvitdzhvbosyepfmqagkuy
145
+cnjxdrqtdzhvbosdewfmqagkul
146
+cnnxpritdzhvvosyenfmqagkul
147
+lnjxphitdzhvbosyewfaqagkul
148
+cngxpritdzhhbobyewfmqagkul
149
+uncxphitdzhvbosyewfmqagkul
150
+cnjxpribdehvbosfewfmqagkul
151
+cnjxppitdqhvbmsyewfmqagkul
152
+gnjxpritkzhvbosyewfbqagkul
153
+znjxpritdzhvbowycwfmqagkul
154
+cnjxpgitdzhvbosyewidqagkul
155
+cnjxhritdzhvbowyswfmqagkul
156
+injxkritdzhvbjsyewfmqagkul
157
+cmjupritgzhvbosyewfmqagkul
158
+cnjxpritdzbvjoeyewfmqagkul
159
+cnjxpritdkhvbosyewlmuagkul
160
+cnkxpritdzhebvsyewfmqagkul
161
+cyjxptitdzhvbosyewfmqagkuv
162
+cnjxpritdzhvbodrewflqagkul
163
+cnjxpratdzhvbksyewfhqagkul
164
+cnjxpoitdzhvbosjewxmqagkul
165
+cnjxprhidzhvbasyewfmqagkul
166
+cnjxpritdzhvbosqewvmqagmul
167
+cnjxoritdzhvbosyzifmqagkul
168
+mnjxpritdzhvbcsyeyfmqagkul
169
+cnjhpritgzhvbosyewfmqngkul
170
+cnjxprijdzevbesyewfmqagkul
171
+cnexprqtdzhvbosyewvmqagkul
172
+cnjxpxitdzhvbosyawfmqmgkul
173
+cnjxpritdzhvbosyirfmqaxkul
174
+cqjxpcitdzhvboslewfmqagkul
175
+cmjxpqitdztvbosyewfmqagkul
176
+cnbxpritdzhvfosyewfmuagkul
177
+cnjxprrtdzhvbosumwfmqagkul
178
+cnjxprttdvhvbossewfmqagkul
179
+cnjxpritdzhvbcsuewfaqagkul
180
+cbjxpritdzhvbosyewfhqalkul
181
+cnjxprithzhvbosjcwfmqagkul
182
+chjxpritdzhvbosyewftcagkul
183
+cnjxprirdchvdosyewfmqagkul
184
+cnjxpritdxhvbosyewfmqcgkal
185
+cnjxpriidchvbosrewfmqagkul
186
+cnjhprizdzhvbosyewfmqagvul
187
+cnjwpritdzhpbosyewfmqaqkul
188
+cnjxpgitfzhvbosyxwfmqagkul
189
+cnjxpjiedzhvbosywwfmqagkul
190
+cnjxpritdzhvbosyewfpqynkul
191
+xnixlritdzhvbosyewfmqagkul
192
+cnjxoritdznvbosyehfmqagkul
193
+cnjxpritdzhvbjsyewsmqagcul
194
+lnjxpritdzhvkosyewjmqagkul
195
+cnjxpritdzhvbosyedfiqvgkul
196
+cnjxpritdzhqbdsyerfmqagkul
197
+cnjxpritdzavbosyywfmqagvul
198
+dmjxprithzhvbosyewfmqagkul
199
+cnjxpriqdzhvnosyeofmqagkul
200
+cnjxpritdxhvboszewfmqkgkul
201
+cnjxpritdzxvbosjewymqagkul
202
+cnjxpritdzngbosyewfmqugkul
203
+cajxpritdnhvbosyerfmqagkul
204
+cnsxpritdzhvbosymwfmqagcul
205
+cnjxoritdzhvbosyewrmqhgkul
206
+cnjxpritdzhvposyewfmqagkwo
207
+cnjxpriazzhvbosyeufmqagkul
208
+cnjxrritdzhvbosymhfmqagkul
209
+cnjxprztdzhvbosyewfmqtgkum
210
+cnjxpritdzhvbmsyewfmqatkun
211
+cnuxpritdzhvbosyewfmqagvur
212
+ctjxxritdzhvbosyewfvqagkul
213
+cnjxpritdzlvbosyevfmqagkll
214
+cnjxpritdzhlbosyewfmqagasl
215
+cnjxpritwzhvbosyewfcxagkul
216
+cyjxpritdzhfbosyewfmqagcul
217
+cnjxpritxghvkosyewfmqagkul
218
+ctjxpritdjhvbosyewfmqkgkul
219
+cnjxpritxzhvbosyewjmbagkul
220
+unjxpritdzhkbosyewfmqaghul
221
+cnjoprqtdzhvbosyewzmqagkul
222
+rnjxprgtgzhvbosyewfmqagkul
223
+cnjgpqitdzhvbosyewfaqagkul
224
+cnjxpritdzuybosyewfmqagful
225
+cnjxprqtdahvbosyewfnqagkul
226
+cnjxpritdzhmkhsyewfmqagkul
227
+wnjxpritdzhvbosiewfmqagkml
228
+cnjmpritdzhvbosyjwfmqagkdl
229
+cnjopritdzhvbksyewfmqrgkul
230
+cnlxpritdzhvbosyewfmomgkul
231
+cgjxpritdzhvbbsyewfmxagkul
232
+cnaxpritdvhvnosyewfmqagkul
233
+cnjxprijdzhvbkmyewfmqagkul
234
+cnjxpritdzhvposyewzmqagkuz
235
+cnuxpuitdzdvbosyewfmqagkul
236
+cnjxprifdzjvbosyewfyqagkul
237
+cnhspritdzhvbosyewfmqaghul
238
+cnjxprcbdzfvbosyewfmqagkul
239
+lnjapritdzhvbosyewfmqegkul
240
+cnjxprisszhvbosyewqmqagkul
241
+cnjxpritdzhvbosyeifmsagoul
242
+cnjxpritrfhvbosyewfmqagkuz
243
+cnjxkritdzmvboqyewfmqagkul
244
+cnjxpritdzhvbosyedfmqzgkzl
245
+cnjxprifdzhvbosyswfmqagksl
246
+cnjxoritdzhvbosyxwfmhagkul
247
+cnjhpritdzzvbosfewfmqagkul
248
+cnjxprityjhvbomyewfmqagkul
249
+cnjbpritdzhvbosyywfmqagkuf
250
+cnjxprrtdzhvbosyewgmqagtul