Overview
Comment: | Add Day 2 input and solutions |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
35dfec6e8d276550930d6f4dc055796b |
User & Date: | joel on 2018-12-02 17:26:22 |
Other Links: | manifest | tags |
Context
2018-12-03
| ||
20:27 | Add Day 3 input check-in: a68afe user: joel tags: trunk | |
2018-12-02
| ||
17:26 | Add Day 2 input and solutions check-in: 35dfec user: joel tags: trunk | |
2018-12-01
| ||
23:16 | Day 1 solutions (both parts) check-in: 6b74a1 user: joel tags: trunk | |
Changes
Added day02-input.txt version [b9a78c].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | mphcuiszrnjzxwkbgdzqeoyxfa mihcuisgrnjzxwkbgdtqeoylia mphauisvrnjgxwkbgdtqeiylfa mphcuisnrnjzxwkbgdgqeoylua mphcuisurnjzxwkbgdtqeoilfi mkhcuisvrnjzowkbgdteeoylfa mphcoicvrnjzxwksgdtqeoylfa mxhcuisvrndzxwkbgdtqeeylfa dphcuisijnjzxwkbgdtqeoylfa mihvuisvrqjzxwkbgdtqeoylfa mphcuisrrnvzxwkbgdtqeodlfa mphtuisdrnjzxskbgdtqeoylfa mphcutmvsnjzxwkbgdtqeoylfa mphcunsvrnjzswkggdtqeoylfa mphcuisvrwjzxwkbpdtqeoylfr mphcujsdrnjzxwkbgdtqeovlfa mpfcuisvrdjzxwkbgdtteoylfa mppcuisvrpjzxwkbgdtqeoywfa mphcuisvrnjzxwkbfptqroylfa mphcuisvrnjzxwkbgstoeoysfa mphcufsvrnjzcwkbgdeqeoylfa mphcuissrnjzxwkbgdkquoylfa sphcuxsvrnjzxwkbgdtqioylfa mphcuiivrhjzxwkbgdtqevylfa echcuisvrnjzxwkbgltqeoylfa mphcuisvrljexwkbvdtqeoylfa mpjcuisvrnjzxwkhidtqeoylfa mphcuisvrfjzmwkbgdtqeoylfl mwhcuisvrnjzxwkbgdtqeoytfm mphcuisvrsjzxwkbgdaqeoylfh mohcuisvrnjzxwkbgdtqtoymfa maycuisvrnjzxwkbgdtqboylfa pphcuisvqnjzxwkbgdtqeoylfd mprcuisvrnjtxwmbgdtqeoylfa mfhcuisgrnjzxckbgdtqeoylfa mphiubsvrnjzxwkbgdtqeoyufa dphctisvrnjzxwkbgdtqeoylfk mphcuisvrnjznwksgdtqeoyzfa mpwcuisvrnjziwkbgdtqaoylfa mphduzsvrnjznwkbgdtqeoylfa mphccisvrnjzxwebgdtqeoylqa xphcuisvrnjzxwkfvdtqeoylfa mphcupsvrnjzxwkbgdtfeoylpa mphcuisvrtjzjwkbgdtqeoylfe mpbcuisvrnjzxwkbgdmieoylfa mphcuisvrnjzxwkbgjtqetylaa mphcuisvrnjzxwpbgdtgdoylfa ophcufsvrqjzxwkbgdtqeoylfa iphcuhsvrnjzxwkbgetqeoylfa mphcuisvunjzxwwbgdtqeoylqa mphcpisvrnjzowkbgdtveoylfa mphcuisvrnjzxhkbgdtqeotlla mphcuisvrnjzxwkbodtgeoylha mphcuisvrjjzxwkbwdtqtoylfa mphcwisvrnjnxwkbgjtqeoylfa mplcuicqrnjzxwkbgdtqeoylfa mphcuisvrnjzxydbgdtqeoylfn ophckisvrnjzxwkbgdtqeozlfa mphcuisvrkjzxwkbgdtteoblfa yphcuisvrnjcxwkbggtqeoylfa mphcuisvrnazxwfbqdtqeoylfa mphcuisvrmjzxwkbgdtlwoylfa mphctksvrnjzxwibgdtqeoylfa mphcuisprnjzxlebgdtqeoylfa mphcuisnrnjzxakbgdtueoylfa mphcuiavrnjoxwtbgdtqeoylfa nphcuisvrnjzxwkbgdtqzoylfk mphcuisrrnjmxwkbgdtqdoylfa mphcuisvrujzxwkvgdtqehylfa mphcuisvrnfzxwkogdtqebylfa mphcuisvrnjwdwkbgdtqeoyxfa mphcuisvrntzxwkrgxtqeoylfa mpzcuisvrnjzxwebgdtqeoylsa aphcuikvrnjzxwwbgdtqeoylfa mphcqisvrnjzxwkpgdtqeoelfa mphcuusvrnjzxwkbgdtjeodlfa mphcuisvrnjzewkbgdtteoylza mphcuisvanjzxwkbgdtheoylfc mphcjishrnjzxwkbgltqeoylfa mpxcuislrnjzxwkbgdtqeoynfa mphcuisvrnjjxwkbgdtmeoxlfa mphcimsvrnjzxwkbsdtqeoylfa mphcxisvcnjzxwjbgdtqeoylfa mphcuisbrvjzxwkbgdtqeoymfa mplcuisvrnjzxwkbgdtaenylfa mphcuihvrnjzxwkygytqeoylfa mphcbisvrnjzxhkbgdtqezylfa mphcuisarnjzxwkbgatqeoylfv mphcumsvrnjzxwkbgdrqebylfa mlhcuisvrnwzxwkbgdtqeoylfx mpkcuisvrkjzxwkbgdtqeoylfo mphcuissrnjzxwkbgdtqmoylfc mphcuiwvrnjuxwkfgdtqeoylfa mphcuicvlnjzxwkbgdvqeoylfa mphcuisvrvvzxwkbfdtqeoylfa myhcuisvrnjpxwkbgntqeoylfa mpocuisvrnjzxwtbgitqeoylfa mphcuisvrnjzxwkbgdtwewyqfa mphcuisvtnjzxwwbgdtqeoolfa mphcuisvrnjzxgkbgdyqeoyyfa mphcuisvrdjzxwkbgpyqeoylfa bphcuisvrnjzxwkbgxtqefylfa sphcuisvrdjzxwktgdtqeoylfa mphcuvsvrnjmxwobgdtqeoylfa mphcuisvrnjzxwkbsdtqeuylfb mnhcmisvynjzxwkbgdtqeoylfa mphckisvrnjzxwkhgdkqeoylfa mpacuisvrnjzxwkbgdtqeoolaa mpgcuisvrnjzxwkbzdtqeoynfa mphcuisvrojzxwkbzdtqeoylga mphcuisvknjfxwkbydtqeoylfa mphcuistrnjzxwkbgdqqeuylfa bpvcuiszrnjzxwkbgdtqeoylfa mphcuxsvrnjzswkbgdtqeoelfa mphcuisvbnjzxwlbgdtqeoylla mphcuisvonczxwkbgktqeoylfa mphcuisvrnkzxwvbgdtquoylfa mphcuisvrnjzxokfgdtqeoylia tphcuisvrnjzxwkbjdwqeoylfa mihcuisvrnjzpwibgdtqeoylfa mphcuisvrejzxwkbgdtqjuylfa mprcuisvrnjixwkxgdtqeoylfa mpqcuiszrnjzxwkbgdtqeodlfa mphcuasvrnjzzakbgdtqeoylva mphcuisvrnjzmwkbtdtqeoycfa mphcuisvrnjzxwkbcdtqioylxa mphckisvrnjzxwkbcdtqeoylfm mphcuisvrnjuxwbogdtqeoylfa mphcuisdrnjzxwkbldtqeoylfx mphcuisvrnjoxwkbgdtqeyyyfa mphcuicvqnjzxwkbgdtqeoylna mpmcuisvrnjzxwkbgdtqktylfa mphcuisvrnqzxwkggdtqeoykfa mphcuisvryjzxwkbydtqejylfa mphcugsvrnjzxwkbghtqeeylfa rphcuusvrnjzxwkwgdtqeoylfa zphwuiyvrnjzxwkbgdtqeoylfa cphcuivvrnjzxwkbgdtqenylfa mphcuisvrnjzxwkagotqevylfa mprcuisvrcjzxwkbgdtqeoytfa mphjugsvrnezxwkbgdtqeoylfa mphcuisvryjzxwkbgltqeoylaa mphcursvrnjzxfkbgdtqeoydfa mphcuisvrcuzxwkbgdtqeoylfw mphcuisvrijzxwkbgdtqeoelfh xphcuisvenjzxjkbgdtqeoylfa mphcuisvrnazxwkbgdeqeoylaa mphcuisbrsjzxwkbgdtqeoygfa mlhvuisvrnjzxwkbgdtqeoylfh mphcuisvrnjzxukbgdtqeoyhfy mpzcuilvrnjzawkbgdtqeoylfa hphcuisjfnjzxwkbgdtqeoylfa mahcuisvrnjzxwkegdtqeoylfi mphcuixvrnjzcwkbgdtqetylfa mphcuisvrnjzxwkdgdtqeoklfj mlhcuisvrnjzxwkbgdteeoylka mphcuifvrnjbxwkrgdtqeoylfa mphcuasvrnjzzwkbgdtqeoylva mphcuisvrnjzxwkboutqeoylba mbhcuisvcnjzxwklgdtqeoylfa mpbcuisvrnjzxgkbgdtqesylfa mphcuisvrnjfswkbgdtqeoylfd mphcuisvrnjzxwkbgdoweoysfa uphcuisvrnjzrwkbgdtqelylfa mphcuisvrnjzxwkbgdtqyoylsi mpqcuiqvxnjzxwkbgdtqeoylfa mphcuisorfjzxwkbgatqeoylfa mphcuisvrntfxwkbzdtqeoylfa mphcuisvrnrzxwkbgdtueoylfl mphcuisvrnjzewkagdtyeoylfa mpocuisdrnjzxwkbgdtqeozlfa mphcuisvrnjjxwkbgdtoeoylfm mphcuisvenjzxwkbgdtqwoylza mpmcuisvrnjzxwkbgdtqeoxlfr mphcuisvgnjhxwkbgdtqeoplfa mphcuisvrnjzowkdgdtqeoyyfa mphcuisqynjzxwkbgdtqeoylda hphcuisvgnjzxwkbgdtbeoylfa iphcuipvrnuzxwkbgdtqeoylfa mphcuisvrnjzsikbpdtqeoylfa mpwcuhsvrnjzxbkbgdtqeoylfa mnhjuisvcnjzxwkbgdtqeoylfa mphcudsvrnjzxwkbgdtqloilfa mpncuiwvrwjzxwkbgdtqeoylfa mphcuisvrnjgawkbgdtqeoylya mphcuisvrnjzxwkbggtteoslfa mphcuisvrnjzxwkbgdvqeoylpe mphcuisvrnczxfkbgktqeoylfa mphcuifvrnjzxwkbgdbmeoylfa mphcuisvrnjytwkbgdtqeoylla mphcuisvrnjzxwkbgdtjeoxlfn mphjuisvrnjzxwkbghtqeoyffa mphcuisvrnjzxkrbgdtqeoylaa mphcbisvrnjzxwkbgttqeoylfs mphkuksvbnjzxwkbgdtqeoylfa nphcuidvrnjzxwhbgdtqeoylfa mphguzsvrnjzxwkbgdaqeoylfa mihcuisfrnjzxwkbgdtqhoylfa mphcuisvrnrzxwpbgdtqesylfa zphcuisvrnjzxwkbddtqeoylaa mphcuigvmnjzxwkbgdtqeoylba mjhcuisvrnjzxjkbgdtqeoylha mphnuisvrnjznwkbgdtqnoylfa mkhcuisvrnjcxwkbgdqqeoylfa mphcuisvenjzxwbbqdtqeoylfa qphcuisnrnjzawkbgdtqeoylfa mphcuisvrdjzxwkbgdtqeoywca mphcuzsvvnjzxwfbgdtqeoylfa pphcuxsvrnjzxwkbgdtmeoylfa mphiuvsvrnjzxlkbgdtqeoylfa mphlqisvrnjzxkkbgdtqeoylfa mmhcuisvrnjzxwkbgatqeoylea mphduisrrnjoxwkbgdtqeoylfa mphcuisvrnjnxwkvgdyqeoylfa mphcuvsvrnjzxgkbgdtqeoylfz mphcuisvryjzxwkbggtqkoylfa iphcuisvrdjzxwkbgotqeoylfa mphcuisvrnjzxwhbgdtqwoyofa mphcorbvrnjzxwkbgdtqeoylfa mghcuisvrnpzxykbgdtqeoylfa mphauisvrnjnxwkbzdtqeoylfa mphcgisvrnjzxwkwgdtqeoygfa mphcuisvrnjzxwkggotqeoylba mphcuesvrnjzxwkbgdwqebylfa yphcuisvrnjzxwkbgdxqeoylja ephyuisvrnjzywkbgdtqeoylfa mfhcuisqrnjzxwkbgdlqeoylfa mphkuisvrnjzxwkbertqeoylfa mphcuusgrnjzxwkbggtqeoylfa mphcuildrnjvxwkbgdtqeoylfa mphcuiuvrnjzlwkbgwtqeoylfa mppcuisvrljzxwkbgdtqeoylfw mphcwiwvrnjzxwsbgdtqeoylfa mphcubivrnjzxwkqgdtqeoylfa mphcuisvrnjpxwkngdtqeoylpa pchcuisvrgjzxwkbgdtqeoylfa mphcuisvlnjzxwkbgdtmeoylfw mphcuisvrnjzywkbgdvqeoylfj mpzcuisvrnezxwktgdtqeoylfa mphcuisvrnjbxwkbgzrqeoylfa mphcuisvrnjzxwktgdtqeodtfa jphcuiavrnjzxwkbgdtqeoylfv mphcuisvrnjzxwkbddppeoylfa mphcuissrkjzxwkbgxtqeoylfa mphcuisvrhjzxwxbgdtqeoylxa mphcvisvgnjjxwkbgdtqeoylfa mphcuisprnjwxwtbgdtqeoylfa mphcuissrnjzxqkbgdtqeoymfa mphcuiabrnjzxokbgdtqeoylfa mphcuisvrnczxwkbgmtpeoylfa |
Added day02.rkt version [200b66].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | #lang racket (require rackunit) (define input (file->lines "day02-input.txt")) ;; Returns hash table where keys are unique chars in str, ;; values are # of occurrences of that char in str (define (check-id str) (for/fold ([seen (hash)]) ([c (in-list (string->list str))]) (hash-set seen c (add1 (hash-ref seen c 0))))) ;; Returns hash table where keys are numbers, values are counts of ;; how many ids in id-list that have a character that repeats exactly ;; [key] times (define (id-counts id-list) (for/fold ([counts (hash)]) ([id (in-list id-list)]) (for/fold ([each-count counts]) ([c (in-list (remove-duplicates (hash-values (check-id id))))]) (hash-set each-count c (add1 (hash-ref each-count c 0)))))) (define (day01-part1 id-list) (define counts (id-counts id-list)) (* (hash-ref counts 2 0) (hash-ref counts 3 0))) (module+ test (define test-ids '("abcdef" "bababc" "abbcde" "abcccd" "aabcdd" "abcdee" "ababab")) (check-equal? (day01-part1 test-ids) 12) (check-equal? (day01-part1 input) 7533)) ; Correct answer for part 1 (define part2-example '("abcde" "fghij" "klmno" "pqrst" "fguij" "axcye" "wvxyz")) ;; Returns a list of characters at positions where id1 and id2 match (define (compare-box-ids id1 id2) (define id1-chars (string->list id1)) (define id2-chars (string->list id2)) (filter identity (for/list ([i (in-range (length id1-chars))]) (if (equal? (list-ref id1-chars i) (list-ref id2-chars i)) (list-ref id1-chars i) #f)))) (define (day02-part2 ids) (define (is-match? comparison-chars) (equal? (length comparison-chars) (sub1 (string-length (first ids))))) (define matches (filter is-match? (map (curry compare-box-ids (first ids)) (rest ids)))) (if (not (empty? matches)) (list->string (first matches)) (day02-part2 (rest ids)))) (module+ test (check-equal? (day02-part2 part2-example) "fgij") (check-equal? (day02-part2 input) "mphcuasvrnjzzkbgdtqeoylva")) ; Correct answer for part 2 |