-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathday1.clj
26 lines (21 loc) · 12.8 KB
/
day1.clj
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
(ns aoc.day1
[:require [clojure.string :as str]])
(def input "4323\n4004\n4070\n1780\n5899\n1912\n2796\n5743\n3008\n1703\n4870\n5048\n2485\n1204\n\n30180\n\n33734\n19662\n\n2402\n4395\n2703\n1562\n2407\n3393\n4311\n1314\n2729\n2225\n4420\n4136\n2867\n1032\n2095\n\n7366\n3496\n6177\n1426\n4750\n2655\n3194\n4240\n4024\n3510\n2606\n2335\n\n1524\n17720\n23749\n\n2549\n1945\n3392\n4965\n5601\n4725\n1462\n1470\n2988\n5339\n1620\n6098\n4447\n5115\n4102\n\n2729\n4836\n10723\n6705\n2278\n3290\n2735\n1813\n\n10285\n2302\n6970\n10710\n8791\n5575\n9765\n2167\n\n1081\n6290\n3701\n2457\n9551\n9625\n3870\n8433\n5653\n\n5647\n2342\n5549\n2861\n4081\n3166\n1902\n3217\n3255\n4353\n1752\n2491\n3271\n4239\n5744\n\n14082\n\n24855\n23123\n18215\n\n9650\n5995\n11848\n1258\n10354\n5948\n9052\n\n5347\n7820\n4620\n4217\n2686\n7163\n4911\n8538\n6851\n8342\n\n6323\n3157\n6939\n3400\n5297\n6815\n1476\n2440\n5816\n6400\n4198\n2356\n\n6537\n2596\n5678\n7605\n1882\n4329\n7488\n6548\n3687\n2827\n1461\n\n4933\n4880\n1169\n4190\n5993\n5452\n5131\n3310\n5996\n2670\n1972\n4666\n3296\n3978\n4119\n\n1372\n2160\n1268\n3378\n5672\n2384\n2772\n2513\n3534\n1372\n4691\n4311\n3016\n5941\n5035\n\n3644\n2169\n5597\n1874\n1841\n1794\n2331\n4907\n1607\n3104\n1893\n2026\n4297\n4078\n\n7561\n8745\n10249\n2438\n4872\n5647\n7849\n6634\n\n21402\n34212\n\n2268\n2107\n3715\n6236\n3881\n6741\n6475\n2999\n4231\n3936\n4840\n\n2318\n5735\n19378\n7775\n\n1848\n12168\n\n3324\n5284\n6502\n5135\n2887\n5849\n4107\n1065\n1236\n1572\n5308\n2337\n5741\n1705\n\n4445\n3494\n4890\n3522\n3456\n3218\n7020\n3640\n4653\n4794\n6003\n4552\n\n13971\n2866\n14359\n1749\n2761\n\n8963\n2088\n6758\n16065\n4613\n\n8406\n3200\n4467\n5892\n6549\n6360\n7789\n1592\n5334\n5007\n\n9335\n9406\n12089\n10628\n8080\n1841\n6973\n\n7553\n10626\n8661\n1747\n4561\n10772\n\n3487\n2524\n2696\n4140\n4367\n2367\n6005\n2465\n2360\n3447\n1242\n6378\n4295\n\n23471\n14744\n19137\n\n15284\n10987\n1491\n17669\n\n2182\n5750\n7466\n1965\n1274\n5648\n7230\n6127\n7768\n5246\n2758\n\n7451\n6614\n6538\n6789\n\n7381\n6243\n3806\n4838\n5163\n2962\n6748\n1982\n1049\n5178\n6590\n3739\n\n1598\n4645\n5128\n3838\n4383\n2742\n1654\n2272\n5518\n1599\n2948\n\n6939\n6508\n4072\n2196\n3589\n1905\n2221\n6003\n6090\n3612\n1791\n5525\n4015\n\n27936\n\n1695\n5271\n5888\n3809\n4023\n4690\n\n4147\n14521\n18575\n11452\n\n2886\n3542\n4260\n5414\n4207\n6920\n3285\n4103\n2480\n5378\n5062\n2587\n1473\n\n6375\n5824\n2640\n1315\n8095\n1743\n3695\n7109\n\n5281\n2346\n4972\n4967\n6804\n1448\n9301\n1234\n\n52340\n\n5369\n5911\n3839\n6600\n4474\n1724\n3595\n3585\n3513\n7336\n2277\n4851\n\n7017\n12732\n9304\n12136\n6256\n12880\n\n3559\n2147\n4293\n1481\n4349\n5624\n3611\n5194\n4575\n1662\n6141\n5599\n1199\n5901\n\n29966\n20696\n\n3317\n4398\n1493\n1730\n2417\n1597\n5310\n5163\n4484\n5160\n1890\n5695\n4027\n4393\n\n13693\n6774\n7495\n9515\n9103\n12116\n\n10203\n26377\n\n6056\n5189\n3946\n3696\n4086\n6017\n7008\n5212\n2740\n7433\n3303\n6170\n\n6140\n3588\n5969\n3308\n3063\n4591\n6575\n\n1803\n8431\n1340\n5409\n12106\n5774\n\n6812\n6740\n1025\n7512\n9778\n7297\n9872\n4269\n\n7012\n1225\n6654\n4828\n4791\n1514\n4144\n5631\n6230\n2530\n6276\n2142\n\n5884\n5873\n5068\n5132\n3739\n4874\n2798\n2461\n6577\n4926\n4343\n1450\n\n68707\n\n4992\n3372\n5660\n7139\n5052\n6115\n1749\n2810\n7021\n5529\n5782\n4395\n\n1953\n4377\n6438\n1987\n5046\n3732\n4600\n5665\n5882\n1974\n6009\n3727\n1134\n\n6339\n5628\n7716\n2740\n8091\n3185\n3877\n2099\n2812\n\n1352\n1928\n2815\n7509\n1311\n6981\n4396\n4094\n3827\n2278\n2727\n\n2249\n4138\n3251\n3581\n4657\n2234\n2070\n1525\n2206\n3512\n5139\n3792\n6039\n5885\n\n5939\n1603\n6497\n4450\n4937\n1762\n1301\n4543\n6872\n4967\n1365\n5738\n2504\n\n22837\n10301\n13380\n\n3714\n1854\n\n2320\n6723\n2994\n3402\n4840\n4613\n3460\n4068\n6575\n4539\n2139\n1206\n3238\n\n1974\n11341\n4645\n12073\n2637\n\n3876\n2380\n7305\n1130\n6134\n7401\n3911\n7322\n6264\n3299\n5164\n1688\n\n5399\n3485\n6861\n4543\n10367\n10255\n\n4451\n2902\n6043\n4384\n4023\n3587\n2836\n5649\n4765\n2051\n1471\n2365\n1038\n2452\n\n11226\n13152\n4749\n9547\n\n5099\n2983\n12118\n9251\n12847\n9391\n\n23810\n22967\n13264\n\n8898\n11599\n3103\n6687\n5592\n3559\n\n14152\n2647\n9210\n\n4675\n5105\n3400\n2991\n1688\n5839\n4746\n6007\n5103\n4212\n3419\n4335\n1974\n2035\n2263\n\n3266\n1208\n4104\n5092\n1816\n4339\n4732\n1746\n2569\n5600\n2329\n1035\n4238\n6095\n5008\n\n17154\n20316\n25661\n\n1199\n\n1285\n6497\n3073\n1862\n6437\n2001\n3807\n3519\n2338\n6727\n1258\n3402\n4825\n\n6970\n8106\n9383\n12577\n\n10963\n5485\n10936\n12139\n8948\n10772\n11053\n\n24569\n16515\n12189\n\n4741\n3247\n4106\n1423\n2540\n2549\n10404\n6570\n\n10768\n23116\n9838\n\n3655\n3142\n3835\n3542\n7419\n5830\n3956\n7272\n1539\n7260\n3636\n4308\n\n1949\n5477\n3960\n1215\n2389\n5869\n5677\n2235\n4273\n6776\n5490\n5299\n4913\n\n3272\n2331\n4138\n2958\n4780\n5427\n5949\n2894\n3669\n4201\n3000\n3387\n1227\n5110\n1990\n\n7239\n18190\n17161\n16971\n\n3742\n2960\n3810\n2564\n1972\n5363\n1675\n2370\n4486\n5243\n4833\n6036\n1590\n6058\n\n4374\n3018\n4827\n4061\n2097\n4819\n2646\n6851\n3864\n1289\n3366\n3328\n2929\n\n16680\n6361\n9020\n14141\n\n12541\n12672\n12624\n\n5794\n7699\n10020\n9455\n1716\n2567\n8294\n1179\n\n8733\n6078\n10818\n2697\n10768\n5266\n5211\n\n9435\n7619\n3382\n14870\n2752\n\n5089\n1720\n1836\n6485\n6459\n4323\n5068\n5987\n2588\n6906\n6899\n4500\n\n6132\n4466\n5913\n1613\n5151\n3915\n4656\n3483\n2387\n1811\n6147\n5757\n6699\n\n4541\n1357\n5762\n1877\n2240\n4025\n5053\n1079\n6121\n8030\n5597\n\n2463\n2185\n2126\n4766\n2069\n4302\n2072\n5028\n1581\n2359\n1914\n4554\n3730\n4141\n1625\n\n5440\n7109\n6947\n4241\n7812\n7923\n9238\n6317\n4657\n\n8064\n5655\n8309\n5404\n4639\n8986\n2719\n3403\n2541\n\n6183\n5137\n7918\n7159\n3194\n3628\n5371\n1554\n3641\n5394\n6931\n\n11367\n16399\n9440\n3911\n\n7952\n5780\n9026\n1500\n3848\n8218\n9643\n6783\n\n1841\n5956\n1547\n5079\n6979\n7912\n2992\n6197\n8715\n\n31416\n13515\n\n5752\n6402\n5541\n2444\n2944\n3826\n6410\n6654\n6195\n3130\n1380\n6102\n5668\n\n3732\n5016\n1813\n5901\n2438\n1416\n8290\n5437\n2402\n7254\n\n31293\n6165\n\n24947\n\n10582\n24078\n25144\n\n11476\n12288\n4678\n4895\n16179\n\n2580\n6573\n13083\n5326\n5067\n\n30550\n\n14659\n2596\n9144\n17320\n\n3546\n14239\n16336\n15317\n5453\n\n3977\n4131\n1046\n6956\n5174\n10004\n8796\n7734\n\n3761\n4088\n2898\n6563\n1891\n3269\n1152\n4755\n3098\n5713\n4203\n2498\n2648\n\n21485\n22269\n\n1620\n1960\n2738\n2963\n1404\n1649\n7600\n1930\n3740\n5450\n7719\n\n3500\n7419\n4550\n3240\n4553\n2453\n1545\n7036\n6217\n1822\n7939\n\n17049\n12540\n17626\n\n3626\n10619\n10814\n4500\n3733\n9168\n5404\n\n3069\n6699\n2440\n5847\n2373\n4696\n6403\n3330\n6840\n5094\n7211\n\n1378\n7603\n2366\n7951\n9178\n4302\n3611\n4883\n\n6816\n4009\n6047\n1044\n1252\n2401\n6354\n4211\n5248\n2811\n1746\n2959\n\n2576\n5322\n4474\n5253\n3873\n6448\n1624\n1986\n1986\n2540\n2250\n5397\n4203\n5733\n\n1853\n5903\n5337\n1648\n7813\n8378\n5571\n5351\n6403\n\n6127\n5397\n2123\n1893\n4920\n6195\n5524\n6428\n4728\n3850\n4327\n2792\n2969\n2220\n\n1591\n4847\n2415\n1107\n1986\n3466\n6095\n7735\n4027\n2370\n7637\n\n3856\n11292\n2699\n14112\n3518\n\n5427\n2633\n6628\n2393\n3645\n2730\n6007\n3798\n1715\n2521\n5221\n5755\n6318\n\n5191\n4058\n3958\n1219\n1664\n2551\n3534\n6406\n5722\n4383\n2105\n6376\n1774\n6175\n\n14330\n9855\n17946\n\n3386\n4396\n3669\n1958\n3971\n1358\n5917\n6026\n4452\n1188\n3052\n2668\n1651\n5408\n4088\n\n5749\n2369\n2628\n4214\n1375\n3109\n2788\n6028\n4984\n3822\n4667\n6093\n3474\n\n1556\n6494\n3916\n5611\n4326\n6483\n2510\n6131\n3110\n2554\n1847\n5859\n2238\n\n1047\n11827\n3359\n8841\n11232\n5803\n9220\n\n5555\n6553\n3903\n3149\n5458\n10593\n8455\n10770\n\n10630\n7727\n6683\n4610\n7987\n7038\n9909\n4599\n\n4637\n1682\n4114\n4940\n2386\n3909\n3110\n1393\n\n6153\n4700\n5461\n7641\n2153\n5363\n\n63414\n\n4467\n1956\n5073\n1822\n9426\n3549\n6866\n4901\n9317\n\n19947\n11533\n16836\n18062\n\n7143\n5185\n13258\n3803\n\n5299\n2684\n2610\n3416\n1783\n5055\n2894\n1164\n4200\n4558\n4380\n3465\n3395\n\n4672\n2427\n6915\n2155\n3306\n4559\n2674\n2230\n6649\n7296\n3433\n\n2191\n4437\n4644\n6313\n1187\n1602\n6811\n1299\n1541\n4973\n2073\n2231\n4216\n\n4893\n8788\n5585\n10703\n9517\n6913\n1333\n\n11440\n25326\n18092\n\n10121\n6807\n4589\n6972\n5842\n8278\n6672\n4871\n\n13690\n7766\n7778\n12899\n3329\n4407\n\n7659\n15344\n17263\n13394\n\n6028\n9037\n2459\n8859\n6934\n5789\n5622\n5893\n8267\n\n10362\n\n5313\n5005\n6354\n3387\n2019\n4933\n4843\n1508\n4066\n1121\n5027\n2157\n2712\n5325\n\n35049\n\n2068\n2489\n2968\n3176\n2835\n1518\n5949\n1106\n1685\n1485\n3896\n4946\n\n5681\n7841\n5218\n5573\n2042\n5725\n6117\n3882\n5360\n1299\n3584\n\n6516\n2684\n6887\n1375\n4296\n7171\n7693\n4603\n8239\n\n7661\n8996\n3419\n4736\n5552\n7873\n8297\n4376\n\n5516\n3278\n2425\n3308\n7722\n5739\n5177\n6738\n9194\n\n13795\n12863\n8108\n9938\n2374\n12314\n\n4931\n6334\n6636\n6256\n1945\n8716\n7054\n2035\n6715\n2180\n\n21075\n7049\n23573\n\n6985\n9970\n9153\n10475\n4568\n6395\n5514\n2117\n\n4115\n2844\n1399\n3535\n4606\n1103\n1443\n5323\n4760\n3992\n5580\n1494\n3193\n5242\n4359\n\n5161\n4143\n7753\n3973\n4318\n5862\n\n1093\n1436\n1444\n4439\n1387\n2114\n4263\n5738\n4607\n5261\n4509\n1389\n4886\n4671\n1154\n\n13316\n14156\n1452\n11726\n4234\n\n8647\n7076\n1481\n1740\n6584\n4276\n1502\n1675\n4012\n7089\n\n8636\n8325\n8445\n4384\n4778\n8110\n10100\n3155\n\n19339\n8585\n5973\n9399\n\n1783\n15809\n1729\n\n3964\n1092\n5948\n8653\n2149\n3494\n7388\n7876\n9334\n\n1211\n4258\n1428\n1096\n3758\n1416\n5969\n5451\n4933\n1057\n1399\n5513\n3655\n3350\n1564\n\n4917\n3980\n5441\n1532\n5716\n2371\n1617\n3153\n1022\n1540\n3450\n2297\n1505\n5188\n2649\n\n2683\n2317\n5457\n9576\n8251\n8707\n1755\n7220\n\n4412\n10875\n10547\n6061\n6221\n2062\n9465\n\n3382\n5259\n3723\n3240\n5556\n4985\n4318\n5831\n2944\n1993\n2127\n4208\n3354\n\n6909\n7400\n4076\n3987\n1663\n7575\n7573\n8001\n1510\n3691\n\n7569\n9266\n1750\n4823\n6919\n5647\n2972\n8801\n8260\n\n3683\n5566\n8718\n4320\n7857\n2501\n1559\n8947\n\n2798\n4808\n3952\n5628\n2242\n1378\n4920\n10266\n\n1457\n7199\n1838\n5849\n6482\n4068\n7236\n1668\n2691\n\n15285\n10046\n11923\n\n1030\n2698\n3211\n7630\n4617\n3383\n1296\n7816\n6360\n7323\n3514\n\n17686\n34956\n\n7398\n2970\n5451\n1272\n1456\n6877\n2549\n4228\n5946\n6077\n6451\n6957\n\n4599\n2727\n2828\n3147\n1487\n2387\n5140\n5558\n6931\n\n4933\n6113\n2104\n6548\n5215\n5627\n6464\n3672\n6387\n3110\n1809\n2780\n1446\n\n5186\n1672\n2253\n3198\n2294\n2995\n5943\n3154\n3667\n5065\n2833\n4049\n2298\n5234\n2856\n\n3558\n2069\n2723\n3908\n6045\n2393\n4610\n1637\n4515\n3961\n1013\n1420\n3111\n1729\n\n17556\n18719\n8542\n7803\n\n1261\n4761\n5767\n4098\n3474\n6178\n6008\n8514\n1956\n\n7007\n4158\n2967\n7673\n5076\n7086\n1105\n7095\n5155\n5637\n2208\n\n4953\n5303\n5460\n5146\n2388\n2298\n1295\n6414\n6323\n4793\n5755\n3878\n1985\n2872\n\n7697\n4701\n1005\n6777\n1763\n5264\n6781\n6600\n1924\n1746\n6696\n\n3932\n3387\n4831\n5621\n5502\n1486\n6377\n6891\n5189\n6879\n2991\n2986\n3450\n\n2929\n2641\n2704\n2693\n6820\n3719\n1908\n2612\n6381\n3258\n1002\n5008\n\n7366\n34310\n\n2798\n5125\n8729\n4928\n1009\n6350\n7994\n2082\n6524\n6253\n\n1723\n1469\n2474\n4565\n1985\n3861\n5804\n3481\n4338\n3580\n2814\n2346\n1635\n4627\n\n13779\n15932\n16875\n2148\n\n8405\n11181\n7324\n10246\n11640\n9061\n2999\n\n2635\n1534\n1223\n1013\n4713\n5928\n5200\n4605\n4520\n1525\n6818\n4778\n3059\n\n3802\n2391\n8430\n10838\n5125\n3233\n11733\n\n47671\n\n11952\n2923\n3109\n4817\n4190\n3666\n11952\n\n8561\n7214\n4010\n7247\n7555\n7647\n3618\n8425\n\n2971\n3620\n5747\n7010\n5404\n2331\n2841\n8718\n2043\n5788\n\n2245\n4763\n6360\n5985\n2177\n6117\n7552\n1784\n4680\n2854\n\n6924\n1946\n5473\n3555\n1298\n1934\n10754\n8047\n\n9028\n1819\n2994\n5197\n8253\n9841\n\n6533\n1279\n4728\n3839\n1054\n2440\n2416\n2840\n4875\n\n5537\n5579\n6856\n4320\n3616\n2177\n6398\n3270\n2763\n1654\n3765\n3727\n3373\n\n6348\n1050\n4641\n4267\n5765\n7125\n2146\n2032\n5863\n3712\n6506\n5430\n\n5288\n7292\n9531\n7158\n11662\n\n8798\n8981\n9789\n16908\n\n5016\n13660\n8515\n5994\n\n4023\n6670\n6553\n4764\n1253\n3340\n5925\n1400\n2684\n5796\n1678\n3324\n\n5489\n1836\n19472\n11219\n\n1799\n4055\n7191\n3511\n9603\n3607\n4621\n8520\n8535\n\n2786\n4514\n3546\n6248\n1984\n3742\n2448\n2319\n3698\n1658\n3949\n6408\n3281\n3804\n\n7413\n3530\n8579\n19575\n\n13921\n5842\n12657\n1413\n9693\n2867\n\n1456\n4298\n1496\n6437\n4283\n2442\n3605\n5482\n6000\n3628\n2020\n2812\n2219\n3000\n\n7965\n3790\n9640\n10772\n9856\n7923\n10390\n\n6009\n2604\n8201\n11341\n7748\n6987\n\n60028\n\n7101\n5285\n9589\n11810\n11534\n4085\n1902\n\n2519\n9496\n2703\n\n3854\n5685\n3541\n3317\n2262\n5910\n3642\n3461\n5759\n3899\n1461\n2692\n6095\n4992\n3739\n\n9302\n4237\n7146\n11412\n9320\n9865\n11517\n")
(defn parse-elf [s]
(->> (str/split s #"\n")
(map parse-long)))
(defn parse-input [input]
(->> (str/split input #"\n\n")
(map parse-elf)))
(defn part1 []
(->>
(parse-input input)
(map (partial reduce +))
(apply max)))
(defn part2 []
(->>
(parse-input input)
(map (partial reduce +))
(sort)
(take-last 3)
(reduce +)))