From c3cddf36063424220ee57567b5e9c2796eb85c5c Mon Sep 17 00:00:00 2001 From: Ben Date: Sun, 1 Dec 2019 18:26:51 +0000 Subject: [PATCH] Moving too the laptop --- 2019/1stDay/.vscode/settings.json | 5 ++ 2019/1stDay/challenge1 | Bin 0 -> 19480 bytes 2019/1stDay/challenge1.cpp | 32 ++++++++++ 2019/1stDay/challenge1.txt | 20 ++++++ 2019/1stDay/challenge2 | Bin 0 -> 19520 bytes 2019/1stDay/challenge2.cpp | 36 +++++++++++ 2019/1stDay/challenge2.txt | 11 ++++ 2019/1stDay/input.txt | 100 ++++++++++++++++++++++++++++++ 8 files changed, 204 insertions(+) create mode 100644 2019/1stDay/.vscode/settings.json create mode 100644 2019/1stDay/challenge1 create mode 100644 2019/1stDay/challenge1.cpp create mode 100644 2019/1stDay/challenge1.txt create mode 100644 2019/1stDay/challenge2 create mode 100644 2019/1stDay/challenge2.cpp create mode 100644 2019/1stDay/challenge2.txt create mode 100644 2019/1stDay/input.txt diff --git a/2019/1stDay/.vscode/settings.json b/2019/1stDay/.vscode/settings.json new file mode 100644 index 0000000..1be854f --- /dev/null +++ b/2019/1stDay/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "files.associations": { + "cmath": "cpp" + } +} \ No newline at end of file diff --git a/2019/1stDay/challenge1 b/2019/1stDay/challenge1 new file mode 100644 index 0000000000000000000000000000000000000000..bb525659dad2e6d2fbac4722970a1622f8e188c1 GIT binary patch literal 19480 zcmeHP4RBo5b-pWEwhYz}1`z>Cybz#vz{{>A%QlQ**V4*wK{BdW0_tEMtKBDQx^xR~6G*g;#@;-a*w~N8+b(}V>JrmXje&{H8(5+6@E z?Aug-PI0+K`OlQ%Pvxpae4xGUszhvUBA(2StsUFYzP7#1lSz46quQ}MEx#=$L6#O*~_;(%b zcfkHR;sP<{w~RGHP8Qrh88a5W;tINF+J&wUjii!##*Cy*T^D+&uSbs=X=5m!F^zOz zPe&q^H2NX~3BzhD-?Dw{4PkS=u1Ckld_G^xKq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|%Re69aYqcmw zAD=>7lmrMpm855j5j_R1+4G5VBONkQOI-To$)_cXrD=t#x$xBaR1Y0Yjm62wP6@^f z3tAf;Q3-ClVQX0bq^ZWi-VqAwr=ECTeH&$WQm$sZ9wrh@;2E_(o-~c2G+ue+Yepn# zh6cI^e3Up#%RuoRvS^(Z!jsuOVnzl)k@_j=FxSX(dQ^ClDbw)a@$MPO#_^vY#A6CV zZs%GvG9+Z%a3nJ#8ig-^Y~qtyQy>R&cbJ&icF`$@GY7z}F=? zcGl;8@0)<*D|A7h_br+7emz8FQD0M-6}O>Ad*j?c?{6}_T1m41EXQ;w+G($ydEN(Q zx?ky&|Kun8uVAqU6^beA^L{B)-tXuBS)a#$ztZ2V4D!AzQ~tey^yxQ-QvHX4QB24` zS$LmSQT|YUxk-ih0r~&EDUCPx&-CA+gWb1+KJRlMK}Hr8mb178 zp7A%)!1o5p@P0V|zd{^Xo}aA8e!UAF8Wa1^`{q;X!uio=FRagW9*uT=;aAdLiyl-g z6V_u&|0R`OpZB#6Dt*3BOZAyw24%8U@ZWE>OtC&0w-vXoPSq8ve +#include +#include +#include + +int main(int argc, char** argv) +{ + std::ifstream infile( argv[1] ); + + int accumilator = 0; + + // for ( std::string line; !infile.eof(); std::getline( infile, line ) ) + // { + + // if ( line.length() == 0 ) continue; + // accumilator += (std::stoi( line ) / 3) - 2; + + // } + + std::string line; + while (!infile.eof()) + { + + std::getline(infile, line); + if ( line.length() == 0 ) continue; + accumilator += (std::stoi( line ) / 3) - 2; + + } + + std::cout << "Sum of the fuel requrements : " << accumilator << std::endl; + +} diff --git a/2019/1stDay/challenge1.txt b/2019/1stDay/challenge1.txt new file mode 100644 index 0000000..e1e8484 --- /dev/null +++ b/2019/1stDay/challenge1.txt @@ -0,0 +1,20 @@ +--- Day 1: The Tyranny of the Rocket Equation --- +Santa has become stranded at the edge of the Solar System while delivering presents to other planets! To accurately calculate his position in space, safely align his warp drive, and return to Earth in time to save Christmas, he needs you to bring him measurements from fifty stars. + +Collect stars by solving puzzles. Two puzzles will be made available on each day in the Advent calendar; the second puzzle is unlocked when you complete the first. Each puzzle grants one star. Good luck! + +The Elves quickly load you into a spacecraft and prepare to launch. + +At the first Go / No Go poll, every Elf is Go until the Fuel Counter-Upper. They haven't determined the amount of fuel required yet. + +Fuel required to launch a given module is based on its mass. Specifically, to find the fuel required for a module, take its mass, divide by three, round down, and subtract 2. + +For example: + +For a mass of 12, divide by 3 and round down to get 4, then subtract 2 to get 2. +For a mass of 14, dividing by 3 and rounding down still yields 4, so the fuel required is also 2. +For a mass of 1969, the fuel required is 654. +For a mass of 100756, the fuel required is 33583. +The Fuel Counter-Upper needs to know the total fuel requirement. To find it, individually calculate the fuel needed for the mass of each module (your puzzle input), then add together all the fuel values. + +What is the sum of the fuel requirements for all of the modules on your spacecraft? diff --git a/2019/1stDay/challenge2 b/2019/1stDay/challenge2 new file mode 100644 index 0000000000000000000000000000000000000000..cddb95506f5f4bf0b7bf36e70d1c52278bfc2619 GIT binary patch literal 19520 zcmeHP4{#jSd4G~DTL$Zo4F+RKd{9H}5+8SxEZb1Sou!jkSh7{01l0UlPIoKm!s$-j z?HQTkV319@C;|^dS|(+Rr==Y=WfHeDNnJMq88aA|He(1irk%E$3^WpU6Z3ZjHC%t+ z+xMMzPq&0POsAdE^XR_!{e9p2-rKjkZ{O$pL+!2QWo3d(g}7c2*16cC1QcVuMO6R- zV!b#Yzh4z!5%Yo1lQfGTumHGL=`VM}Dn+jVB)u`kFNT*XIfm>ZLDF+86V(=np{TQP z(yOGZ!i(YC)DaYh%rCU(k!&G~;H%1ihITzNIkv{q8{6oF%P0USKJJY2i_DSUxY8R} zdJKhXk0HmC%+TKpieC&{z@x&DWT|w%ZN{kX^AI*0nig3wWWC>mo(h?g_%wo zi_0y_e})u)D%T|9Jxz_*Bw}k4@nm*r&CvR$HBF7)Ov+m?`+Xr~D5RUWc8kyMKfUd; z{^qAQo`2%GgKvKQx%|)1OOW5>1KA@PDkN_YC(SkDTm7n&b)J7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^0-4V%TNI-Ah9_$F|p{*^HXQks&RS#*3sI_bt zddu%`4R*9OgXic*%t?@$T7~AewYG*s$Ycs`Y7dcBXO>7HAX7e6Hiy1r$JPzV3PP@Sz^NSQ&#PiJSiL2nuCs@G+@6B20#!W-bZ->-)wI}NLq zmU@+S^}msUq{6jW_6VG6H&Q1T){6?Hiqz3G&^D|?N8^;p&)gDzt* zihNjOC~6FvI^4(oO4_iV*en}dM^ll3coZrrSjUf7Hffp1!XmtQcBJD-&d1$z#%O<= z9;NYGD+})nGUWYj#g?*MC-__V!=rpbpZ5`*ni%SWXSFF`v@NM9c3#p+H+@p-nV3UNHOsGB>T?#ygz;u=y(M$==1(2L*Cbi zh%D;0g;8+_YP5&W?ejh;!)ui!`_FO=?*gCp|H_cROOQT&izwEA1T=~X`6mnS$12F*Uzkn4+Di_IUEibh z82X9=USwW8UZl_a84UMv$5o@O&pv#oNT0tWG34({EMM&Z0j1CJ7ak?4An&UvY9W4% zkD)?cWPP8<;xH^;CyLwuVUhlr(q~x3hAp$R+8-~{=lyGjmn%I6MZ+Op1EU6iG&ia6 zej)$=IK}bi`NQzvp@Utzf!)Y+>`XZpDeHI*3C4#*{u^r^Wh=FMu-H zD)=9;IOD8O#%;x8t5bE6YF~*LxU8?X2McsIXNN^oOv;{A2JgiF3l+K#)#H!*&HW-a h`;Ka%tXB)?fYN6Mx63&BS4#gcnk|W?MG8fz_#aF3Fo*yE literal 0 HcmV?d00001 diff --git a/2019/1stDay/challenge2.cpp b/2019/1stDay/challenge2.cpp new file mode 100644 index 0000000..056100e --- /dev/null +++ b/2019/1stDay/challenge2.cpp @@ -0,0 +1,36 @@ +#include +#include +#include +#include + +int fuelForMass ( int mass, int accumilator = 0 ) +{ + + int res = (mass / 3) - 2; + if ( res > 0 ) + return fuelForMass( res, accumilator + res ); + + return res; + +}; + +int main(int argc, char** argv) +{ + std::ifstream infile( argv[1] ); + + int accumilator = 0; + + + std::string line; + while (!infile.eof()) + { + + std::getline(infile, line); + if ( line.length() == 0 ) continue; + accumilator += fuelForMass( std::stoi( line ) ); + + } + + std::cout << "Sum of the fuel requrements : " << accumilator << std::endl; + +} diff --git a/2019/1stDay/challenge2.txt b/2019/1stDay/challenge2.txt new file mode 100644 index 0000000..6d7a5a2 --- /dev/null +++ b/2019/1stDay/challenge2.txt @@ -0,0 +1,11 @@ +--- Part Two --- +During the second Go / No Go poll, the Elf in charge of the Rocket Equation Double-Checker stops the launch sequence. Apparently, you forgot to include additional fuel for the fuel you just added. + +Fuel itself requires fuel just like a module - take its mass, divide by three, round down, and subtract 2. However, that fuel also requires fuel, and that fuel requires fuel, and so on. Any mass that would require negative fuel should instead be treated as if it requires zero fuel; the remaining mass, if any, is instead handled by wishing really hard, which has no mass and is outside the scope of this calculation. + +So, for each module mass, calculate its fuel and add it to the total. Then, treat the fuel amount you just calculated as the input mass and repeat the process, continuing until a fuel requirement is zero or negative. For example: + +A module of mass 14 requires 2 fuel. This fuel requires no further fuel (2 divided by 3 and rounded down is 0, which would call for a negative fuel), so the total fuel required is still just 2. +At first, a module of mass 1969 requires 654 fuel. Then, this fuel requires 216 more fuel (654 / 3 - 2). 216 then requires 70 more fuel, which requires 21 fuel, which requires 5 fuel, which requires no further fuel. So, the total fuel required for a module of mass 1969 is 654 + 216 + 70 + 21 + 5 = 966. +The fuel required by a module of mass 100756 and its fuel is: 33583 + 11192 + 3728 + 1240 + 411 + 135 + 43 + 12 + 2 = 50346. +What is the sum of the fuel requirements for all of the modules on your spacecraft when also taking into account the mass of the added fuel? (Calculate the fuel requirements for each module separately, then add them all up at the end.) diff --git a/2019/1stDay/input.txt b/2019/1stDay/input.txt new file mode 100644 index 0000000..367b19d --- /dev/null +++ b/2019/1stDay/input.txt @@ -0,0 +1,100 @@ +54755 +96495 +111504 +53923 +118158 +118082 +137413 +135315 +87248 +127646 +79201 +52399 +77966 +129568 +63880 +128973 +55491 +111226 +126447 +87017 +112469 +83975 +51280 +60239 +120524 +57122 +136517 +117378 +93629 +55125 +68990 +70336 +115119 +68264 +148122 +70075 +106770 +54976 +123852 +61813 +113373 +53924 +59660 +67111 +52825 +81568 +110842 +134870 +135529 +78689 +129451 +96041 +91627 +70863 +100098 +121908 +96623 +143752 +149936 +116283 +149488 +126158 +106499 +124927 +109574 +70711 +139078 +67212 +124251 +123803 +73569 +145668 +96045 +59748 +123238 +68005 +121412 +97236 +104800 +86786 +141680 +123807 +82310 +76593 +146092 +82637 +92339 +93821 +56247 +58328 +90159 +105700 +57317 +69011 +125544 +102372 +63797 +92127 +111207 +77596 \ No newline at end of file