-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathday1.js
208 lines (201 loc) · 14.6 KB
/
day1.js
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
let leftList = [
38665, 84587, 93374, 68298, 54771, 49242, 66490, 65908, 71704, 38086, 14187,
20532, 65614, 11304, 25362, 72055, 49666, 66173, 40837, 35579, 61232, 52091,
18314, 35195, 54331, 33400, 79533, 77040, 26223, 88815, 45794, 13890, 19261,
90088, 42316, 25415, 28956, 52792, 88503, 68711, 77367, 50643, 55410, 33112,
23414, 27170, 49843, 73574, 71297, 41032, 54311, 67629, 18536, 10030, 20745,
57680, 90422, 20305, 15917, 99356, 51850, 76292, 98063, 12191, 97360, 33211,
42295, 79769, 51924, 43683, 39179, 60185, 57990, 77295, 24790, 28283, 99413,
56701, 41134, 26842, 90263, 96726, 95896, 30992, 12686, 10520, 92588, 89222,
48462, 77694, 29215, 42318, 84819, 91225, 31832, 38087, 81945, 77457, 61439,
40369, 88405, 66223, 95105, 90075, 69993, 48011, 29342, 85052, 98660, 94197,
93139, 68878, 71619, 46977, 11904, 47001, 82065, 29721, 31105, 97028, 29016,
69812, 36533, 25894, 26266, 90634, 46563, 79665, 80709, 26878, 56666, 34285,
28183, 96099, 88880, 23770, 81640, 71390, 54825, 36741, 80851, 21007, 81349,
57834, 27735, 84023, 38920, 17430, 99043, 94223, 94457, 72780, 32444, 62372,
51087, 93830, 42686, 57610, 45047, 98633, 63847, 68513, 49453, 55946, 50856,
45789, 72205, 31505, 64173, 98155, 70753, 29611, 11137, 32909, 63679, 83794,
99292, 54713, 11146, 37838, 13697, 25542, 83440, 78504, 22763, 27994, 30091,
62383, 18984, 16901, 92207, 73811, 81337, 67498, 47293, 50722, 18778, 97503,
79922, 53969, 15725, 27233, 15530, 90382, 99242, 23566, 21127, 37703, 52108,
36769, 33909, 48827, 76362, 59133, 39132, 99081, 76480, 25596, 50235, 28581,
16076, 17720, 71042, 15240, 19831, 44116, 63696, 41286, 98194, 50004, 41887,
76711, 99317, 13613, 16137, 42410, 34169, 44621, 72734, 61396, 36759, 84702,
85816, 24559, 22316, 52032, 15164, 85163, 47197, 14939, 17851, 39134, 93005,
12738, 70180, 36942, 64429, 13719, 36494, 70321, 24536, 43234, 88874, 96469,
98916, 70083, 58578, 80256, 37111, 68334, 46279, 30153, 37211, 50865, 98773,
59655, 34197, 65623, 39161, 92822, 97609, 28771, 72903, 81696, 66299, 16467,
66035, 33128, 92747, 40431, 40139, 28567, 69276, 50958, 95107, 98949, 97628,
75515, 38185, 64872, 69156, 17320, 29089, 19121, 69225, 70618, 23028, 25084,
74004, 34216, 71767, 11957, 43970, 50265, 65867, 82785, 28455, 13521, 52870,
81192, 52922, 15786, 34277, 50204, 68620, 56877, 64217, 67705, 44264, 15673,
97395, 89037, 74355, 60861, 35556, 48771, 83628, 76214, 58893, 99933, 86446,
75068, 85752, 70300, 61613, 98122, 41327, 65845, 70915, 75864, 38907, 52791,
99407, 83332, 30046, 56280, 32820, 70360, 67702, 97945, 57069, 58962, 68107,
84616, 39475, 14462, 10512, 74047, 32711, 67494, 90232, 10100, 78048, 13711,
21916, 62495, 37116, 80569, 74392, 26299, 58164, 93301, 31492, 39217, 34327,
18995, 24310, 66983, 28500, 34429, 64239, 24999, 74548, 25193, 87634, 36216,
10539, 22373, 28271, 88135, 99042, 33745, 12552, 42209, 96584, 66574, 78799,
57785, 63996, 32612, 74135, 81597, 42352, 54028, 69223, 21961, 71713, 42402,
10187, 41391, 14008, 27601, 86754, 47563, 88397, 95933, 51110, 29218, 81675,
80008, 26022, 39436, 48267, 51817, 11794, 11942, 69074, 18276, 61242, 28019,
91583, 68925, 32977, 94066, 53400, 76152, 71159, 24577, 36582, 18545, 70021,
48132, 32662, 74173, 59697, 69712, 55124, 86734, 48215, 64457, 85581, 92549,
86765, 44235, 50083, 50955, 15649, 94781, 21206, 34265, 40811, 87874, 70458,
92312, 36568, 75301, 60353, 12017, 97966, 40099, 45330, 11169, 52723, 46147,
53464, 12372, 68430, 76667, 18478, 33036, 37748, 57523, 87808, 19190, 90952,
46734, 78907, 96825, 78394, 60807, 64419, 40450, 16354, 69859, 13174, 85959,
88893, 92814, 16069, 58002, 20706, 17456, 83405, 80504, 59608, 33397, 36077,
25987, 65373, 37740, 38356, 85528, 43918, 82475, 65544, 31908, 85860, 35879,
68599, 14439, 73065, 67664, 82582, 47118, 93925, 39481, 98663, 37035, 50493,
78937, 48997, 26389, 76502, 54048, 61512, 72545, 13520, 16203, 47959, 94130,
88634, 53658, 97819, 36711, 87772, 61876, 51529, 35807, 44953, 70153, 65079,
28302, 59791, 50031, 49911, 61691, 79056, 82950, 59675, 21426, 58151, 26165,
66334, 64251, 63877, 14334, 90265, 12748, 98964, 11779, 40927, 29347, 18654,
41982, 41061, 99743, 74706, 90649, 28087, 61623, 35482, 86232, 49404, 48773,
22883, 83697, 34536, 44723, 46576, 29335, 79309, 10842, 37354, 59095, 88910,
31145, 75800, 93227, 30615, 92536, 42177, 71915, 54908, 52410, 58860, 47343,
83166, 28695, 30502, 29426, 86870, 17529, 65007, 78234, 23560, 87097, 22813,
62736, 29232, 81273, 63464, 40338, 62952, 95434, 63468, 56391, 98254, 97351,
63858, 80354, 98241, 67372, 51069, 14868, 10031, 97140, 99808, 70161, 81198,
60987, 95339, 60207, 65344, 42950, 51281, 79929, 51354, 14166, 82199, 39919,
57217, 34854, 63864, 43075, 45248, 46089, 20772, 70932, 86122, 15946, 44156,
63406, 44895, 90340, 91379, 51114, 70653, 82940, 71528, 87955, 28669, 45992,
97984, 85927, 59864, 81438, 70025, 38903, 58887, 39857, 13712, 44188, 40114,
44974, 25231, 88262, 35812, 95724, 52221, 71914, 66450, 91063, 18039, 49797,
60130, 83369, 94570, 68981, 24212, 15349, 99577, 10755, 85659, 49805, 60370,
41005, 48898, 63523, 86663, 21080, 19056, 56722, 55163, 19443, 37944, 49518,
97379, 88699, 68077, 79404, 45236, 59604, 34844, 16235, 86716, 82314, 40678,
20081, 49118, 99420, 71525, 45626, 42374, 63866, 29757, 56979, 73653, 43214,
37922, 48491, 12177, 83955, 57390, 42917, 64244, 89659, 65030, 15320, 59298,
64962, 79362, 58454, 53455, 87564, 10856, 80046, 26163, 85881, 31247, 96730,
96991, 50081, 53175, 58546, 88985, 38660, 57474, 10014, 85636, 39376, 30210,
73530, 45106, 33710, 86137, 51447, 93857, 10519, 67406, 12115, 81188, 22840,
77432, 79648, 27118, 33846, 57622, 77323, 97115, 36521, 17575, 31306, 28458,
97806, 75061, 24370, 85540, 68803, 79880, 49584, 28231, 69126, 68684, 97489,
21553, 18300, 93378, 18477, 65798, 81412, 23459, 52036, 97430, 60092, 38308,
58067, 62704, 50105, 59790, 79629, 27870, 81277, 60415, 63609, 65271, 90053,
92015, 61636, 39029, 88319, 90430, 50684, 49781, 90672, 54006, 18335, 68550,
17242, 56443, 13025, 88580, 57505, 73928, 50645, 34654, 16150, 59245, 41292,
37153, 40119, 15038, 51995, 72008, 39351, 94307, 65374, 33818, 35632, 13340,
64037, 11327, 94027, 74680, 90499, 84533, 70349, 86058, 70971, 37024, 28948,
44022, 75811, 81326, 61416, 34737, 55533, 28249, 16982, 86902, 97265, 13441,
53639, 59068, 93717, 92354, 71611, 18339, 80948, 41117, 82662, 46322, 63147,
35846, 13358, 29798, 35165, 64871, 59660, 77415, 76862, 28351, 83371, 19365,
61679, 25350, 28686, 11232, 25291, 18993, 35849, 59974, 93998, 23836, 21732,
17870, 74048, 90162, 66432, 46585, 80339, 19048, 91316, 31309, 62174, 11790,
51587, 38597, 44150, 33021, 39620, 86129, 53864, 90229, 48614, 81933, 62593,
51827, 54166, 87787, 76553, 99790, 41931, 29481, 85717, 92701, 99720, 73397,
41967, 98617, 84742, 74648, 10822, 27527, 57643, 54079, 16272, 55222, 38368,
16765, 20650, 99345, 81256, 85730, 83538, 55581, 45860, 20126, 87771, 43945,
38415, 76611, 60655, 38694, 74603, 70755, 41002, 92389, 54955, 57931, 71840,
14770, 58532, 38395, 16941, 10544, 64876, 56992, 50084, 79209, 39667,
];
let rightList = [
13337, 21418, 50722, 57474, 18244, 83955, 44116, 51323, 87343, 70349, 91077,
16203, 30387, 65867, 70932, 26767, 31944, 31095, 26167, 85581, 50722, 67378,
15102, 61300, 72814, 72890, 70349, 19254, 16941, 52540, 61915, 27233, 96273,
40968, 43945, 83221, 50722, 27899, 29185, 36941, 63468, 31908, 58164, 20034,
80569, 27626, 32511, 69852, 54016, 17525, 31743, 67059, 98194, 63468, 46576,
67071, 16941, 70932, 19741, 86711, 54713, 92167, 13065, 25063, 72545, 57474,
31908, 50722, 52337, 76152, 71113, 16467, 77323, 46576, 91936, 13191, 85581,
27233, 93737, 44188, 70349, 83955, 19235, 43359, 78261, 38756, 11945, 88586,
70932, 46576, 51794, 57474, 63468, 67702, 19567, 43275, 67194, 63696, 63696,
74690, 67702, 54787, 45844, 12214, 34197, 34540, 50722, 11794, 71704, 97300,
68070, 76000, 27922, 48818, 63858, 16770, 34197, 82754, 63940, 78838, 34194,
97395, 57474, 44188, 23023, 58164, 91672, 95153, 15843, 27870, 34536, 34197,
86861, 97197, 97395, 50339, 33646, 63858, 88538, 57877, 51129, 70932, 13098,
57695, 15100, 83399, 53026, 65867, 79360, 84028, 66299, 93015, 68923, 31856,
99720, 98194, 83955, 34197, 65867, 89719, 77323, 57474, 65867, 28322, 97261,
16941, 17456, 66299, 66299, 50955, 76627, 70932, 42292, 34197, 11794, 44116,
70016, 68852, 44116, 59069, 48336, 46576, 65867, 45977, 81348, 16941, 16467,
85581, 11794, 66299, 33901, 70932, 17817, 63696, 78566, 20178, 71704, 65321,
50722, 16941, 90452, 17456, 98194, 97161, 65867, 79922, 21048, 81444, 57474,
70932, 82199, 76724, 71704, 14778, 80569, 57474, 66540, 34197, 11525, 76932,
31849, 31475, 20206, 76152, 98187, 67702, 45629, 97395, 20678, 64228, 34197,
70349, 80569, 65867, 63696, 43945, 45927, 21038, 63696, 84310, 66120, 65867,
18236, 54693, 34536, 18454, 39543, 16941, 87792, 55106, 63858, 75532, 34536,
88547, 23031, 29745, 28730, 62682, 76152, 58692, 67702, 50722, 54713, 43346,
38515, 62273, 11794, 16203, 77602, 82082, 46576, 34746, 98194, 79922, 82616,
56203, 76152, 93234, 79718, 50722, 16798, 85581, 28436, 56694, 97864, 69051,
16941, 81165, 27870, 15562, 79922, 56965, 61616, 39665, 85581, 96754, 83955,
15021, 80831, 34197, 97395, 56612, 34197, 50812, 60185, 83315, 28786, 98236,
20010, 17456, 44188, 79477, 71470, 45492, 84267, 59825, 65867, 77323, 24028,
76152, 50955, 27233, 57816, 77323, 98054, 83955, 57474, 85581, 91864, 76152,
27233, 46576, 54515, 65867, 16467, 82369, 44116, 99720, 73397, 65077, 63468,
66574, 61667, 97395, 63858, 63696, 45689, 73173, 82199, 70932, 83673, 16941,
50281, 62140, 41764, 63858, 59359, 76152, 50722, 49745, 10905, 77365, 15986,
97395, 16203, 57474, 88977, 17456, 12367, 66299, 40939, 28855, 56287, 49326,
81443, 46576, 63468, 81942, 83955, 63071, 63696, 57474, 77650, 44247, 70932,
39486, 94657, 99720, 17603, 77987, 41386, 99720, 16203, 40228, 16467, 74814,
89684, 76152, 95381, 34536, 13284, 70042, 10822, 91001, 88339, 87712, 85581,
99568, 27233, 85581, 63468, 76152, 16203, 50822, 34197, 96505, 34536, 59457,
99720, 65867, 63696, 88355, 83955, 50722, 61525, 97395, 76908, 98194, 14234,
76613, 88164, 46576, 34536, 99848, 85581, 91990, 84725, 34197, 85690, 36351,
85990, 58164, 16203, 80569, 91931, 72545, 78789, 73397, 86986, 46576, 45875,
46576, 63468, 34197, 35602, 75255, 68594, 15493, 29682, 46576, 47129, 32388,
77920, 56256, 19461, 49307, 97794, 63696, 57474, 45507, 11794, 99720, 90059,
46801, 79557, 38349, 41935, 63468, 29539, 57474, 64697, 50722, 16941, 85581,
97395, 16941, 17456, 17456, 19709, 33716, 72663, 21097, 27704, 83955, 57652,
65867, 73446, 11806, 17236, 63887, 63696, 98194, 63468, 69643, 77323, 99060,
76152, 65729, 98551, 27233, 71704, 99720, 44116, 27233, 94865, 60450, 17910,
65867, 77323, 43945, 66574, 49178, 11461, 99720, 52765, 40160, 48252, 39980,
93267, 24271, 96330, 11794, 31908, 70349, 71431, 67702, 54438, 40058, 99720,
46576, 16941, 23726, 91617, 84837, 83104, 91243, 88435, 27033, 97395, 11794,
85581, 26617, 63858, 61581, 33784, 66299, 70308, 88824, 80821, 79922, 34536,
71704, 39097, 49001, 54999, 16941, 94143, 88152, 63696, 27902, 31908, 29349,
69031, 77323, 66299, 22943, 79903, 70354, 17017, 76152, 49764, 83807, 23753,
79922, 51130, 76574, 94894, 20183, 87075, 63858, 30426, 71704, 34407, 33917,
40378, 78156, 17456, 99720, 69206, 46576, 34536, 57474, 27233, 63696, 88060,
30503, 99469, 20721, 40084, 16246, 57160, 64478, 96661, 44116, 55187, 23616,
11794, 88377, 76748, 11794, 63468, 89533, 71704, 52721, 34536, 10822, 57474,
64591, 11670, 16872, 27233, 63468, 34536, 97809, 83955, 57474, 88672, 98194,
66299, 68260, 25344, 85581, 27233, 22589, 66299, 15068, 24686, 70932, 66299,
82199, 16467, 64182, 99769, 57474, 67702, 70492, 76152, 73397, 76152, 66473,
58383, 71106, 77393, 27233, 58919, 70932, 63858, 73397, 67702, 24462, 88833,
90699, 44116, 63468, 36236, 79922, 54713, 31152, 42570, 66299, 88159, 63468,
34536, 34536, 55650, 17456, 70932, 10947, 44116, 54321, 96493, 70627, 24057,
43945, 46576, 63858, 80569, 43945, 99720, 60089, 16093, 57985, 76152, 11794,
20342, 77446, 97395, 18718, 30602, 33310, 24360, 46576, 16941, 66632, 16941,
11660, 92579, 85581, 11794, 38278, 84772, 22930, 17456, 86124, 66574, 40633,
11165, 46576, 66299, 76152, 50722, 58164, 63696, 43945, 55329, 34197, 38019,
57474, 86999, 22991, 27223, 76152, 44116, 50824, 85581, 99720, 71704, 41698,
60188, 96843, 57474, 63858, 58164, 79922, 63468, 11450, 63858, 16410, 35208,
77954, 80743, 20071, 57474, 81411, 20535, 55549, 36603, 96592, 66299, 40912,
62489, 37795, 16203, 58164, 51240, 50722, 85581, 63858, 11794, 33379, 82145,
17838, 97255, 78685, 55699, 43945, 35385, 44188, 37808, 16203, 74964, 75860,
13166, 24017, 44116, 11794, 10822, 50436, 54713, 89820, 28629, 46576, 41012,
64446, 65867, 63468, 67702, 54097, 63468, 85070, 43581, 45784, 75365, 83924,
45897, 11794, 61443, 66176, 65125, 16467, 65867, 63858, 67702, 46098, 84883,
71647, 70932, 54713, 79806, 70349, 67066, 82199, 70349, 66190, 67702, 49879,
13892, 16941, 97395, 11794, 16941, 73350, 57474, 99720, 23608, 97395, 83955,
98714, 78472, 78528, 57328, 20525, 63858, 79922, 79349, 79038, 99720, 17670,
16827, 70349, 16653, 51842, 63696, 20612, 77323, 63468, 80569, 36792, 66299,
11794, 57198, 70932, 72545, 69512, 54713, 58164, 83955, 33938, 34536, 52419,
14761, 72545, 64922, 73312, 24227, 61805, 65867, 80433, 12617, 71704, 78189,
12907, 11794, 94858, 92976, 76984, 88783, 46576, 19375, 38645, 16203, 77753,
43313, 76152, 27233, 76152, 18525, 14589, 26565, 16941, 59870, 83955, 55304,
99720, 99250, 26917, 54597, 73397, 34536, 35298, 81973, 34536, 83955, 11794,
67702, 82199, 16203, 68461, 46576, 35328, 52750, 20240, 30857, 35350, 46576,
16203, 39285, 65867, 34536, 47484, 85581, 63696, 99720, 58164, 97395, 46107,
65867, 50722, 30910, 44116, 69614, 43945, 70932, 84033, 33388, 28016, 67702,
26222, 44582, 96386, 43461, 99720, 61207, 13131, 95773, 70349, 70932, 63858,
27233, 13111, 34536, 58260, 72175, 70258, 46488, 54713, 77323, 14424, 66356,
70932, 27233, 34111, 99720, 54504, 30309, 27233, 89555, 65867, 37576, 74455,
40677, 11794, 17456, 32946, 70349, 16941, 50668, 16941, 60704, 36867,
];
leftList.sort((a, b) => a - b);
rightList.sort((a, b) => a - b);
const distanceArray = leftList.map(
(element, index) => element - rightList[index]
);
let totalDistance = 0;
distanceArray.forEach((num) => (totalDistance += Math.abs(num)));
console.log(totalDistance); //part 1 answer
let similarityScore = 0;
for (let index = 0; index < leftList.length; index++) {
similarityScore +=
leftList[index] *
rightList.filter((element) => element === leftList[index]).length;
}
console.log(similarityScore); //part 2 answer