From 81172af9dfcbb2c4f5a4b3ed082b844616f4e357 Mon Sep 17 00:00:00 2001 From: "sigonasr2, Sig, Sigo" Date: Fri, 15 Jul 2022 15:48:28 +0000 Subject: [PATCH] Co-authored-by: sigonasr2 --- archives/12/current | Bin 0 -> 16696 bytes archives/12/src/main.c | 53 +++++++++++++++++++ archives/12/src/utils.h | 7 +++ current | Bin 16792 -> 16696 bytes src/main.c | 112 ++++++++++++++-------------------------- 5 files changed, 99 insertions(+), 73 deletions(-) create mode 100755 archives/12/current create mode 100644 archives/12/src/main.c create mode 100644 archives/12/src/utils.h diff --git a/archives/12/current b/archives/12/current new file mode 100755 index 0000000000000000000000000000000000000000..cc6e1259c657507bb22abfd610f08633ee39fc4c GIT binary patch literal 16696 zcmeHOU2GKB6~61WVKJ~?2qXp?Jft8&BM&wK*91{^ZLb+e<|kk$R6vHccWiIt-F0?n zi5(?`)Fjf%xJ6Z^(jTcwUs^Sdn!eG8wkD)NADY5LE7~+Fi3&A^q=q_)(-gMn+&O1G zGhS0E>RabpyXT(oobTK_XYS12@!b1-w7s>==M!A~;!6UxLm>+ZlVNZ(RX~JAqgV*v zHDaZh1A4i{EPL1zV71DnGN%j>?gxpyYOIuypR-`Wl6!~}d9xPm5Ehnn9LTFcoOHMR zJ@u0%+l%cfNQR=w@1i`34p3OydDw+hwbCq3ZFS0h)ZQVI%tIA<=ZSZocq}KVJ(iqL z%n5!PDW7hsfDMZxzlCt~_7Tr5Tgaa!wt;2u6*K->+S^S$O_5=QTXH)rxxGh$$EVa{ z-u;_T^B!t%w)3D-{#jCb#rpn4SHs5j{qfrVL@GB}JJ{Gz+ptm1rqvCyVeA*Sfn#d> z&Q1Yg#t@@4%5$-VbhK91V%<{DjaHWK8K46PW;HzfA_XDn!@c+szIL3aUguj5ic4HbF#6TvI zGJAxscMrz&o6Is*9 zbnIyEPp6EISXVzXdz0xDF?Gweq$75#jIzwR_6hu(zCGlYC+4BoLv##${ql7aUSt`@ z==x+_5FQ9ycE(x1geL?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bcP#s74XA zmOVn>-oC3T(ys4nZQUE~&^sbc?NN*>cd~S6bF#;G-@9VOV`hxD#Dv3+Eidj3F>W(5 ztz9qBq;m_59?z!rzE~=b+hf{xfmb|{(sNk@4sp77m?Y4t3;fj zNK;#_8S53&9o|s%2{k^Hf+j3!W-QBLBa=;}Qw~K3TgK>*A%SWG{iaamk*iQud()s| zC2MpG)iee{#c>ASX?bc?qmM>bUmT*bX2r0En8n~aG!;uGAecpm>jwZxO$V{Kn~rnkDB6`B-=JUjYnr!tvop$|@w?GdcJ9|DKDl z5U(gH91B-?@k19sOb#sBe>VQ>EF}SZeXx&3_v#c0NB}uneHlR(Sj{bOkDS zjqqb3&qsNmuiKw>mN$W0W#jYn%2+LcP}tAXrgg?|g8|1bx6kur-nY&Bv+?@F!aP2Y zuL6dL$b5eOIYkpU4N11be3o;7Z0CzGIoDZ|+u;z*V|@XT5##oGz850C+aKGqmqpY* zxfe~$hh^T5!hE~rv14}(Q^0DvG29PE6+YY_zOT#!jQeiq@53J^DCMr;+^%KCId^IP Ofkw+?xr^XZ#eV=xpS1%3 literal 0 HcmV?d00001 diff --git a/archives/12/src/main.c b/archives/12/src/main.c new file mode 100644 index 0000000..28b6430 --- /dev/null +++ b/archives/12/src/main.c @@ -0,0 +1,53 @@ +#include +#include "utils.h" + +/* +The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be: + +1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ... + +Let us list the factors of the first seven triangle numbers: + + 1: 1 + 3: 1,3 + 6: 1,2,3,6 +10: 1,2,5,10 +15: 1,3,5,15 +21: 1,3,7,21 +28: 1,2,4,7,14,28 +We can see that 28 is the first triangle number to have over five divisors. + +What is the value of the first triangle number to have over five hundred divisors? + +https://projecteuler.net/problem=12 +*/ + +int main(int argc,char**argv) { + int counter=1; + long sum=0; + while (true) { + sum+=counter; + printf("Checking %ld...\n",sum); + int current=1; + int max=sum; + int divisorCount=0; + while (current500) { + printf("\n\nNumber %ld has %d divisors!",sum,divisorCount); + return 0; + } + counter++; + } + return 0; +} \ No newline at end of file diff --git a/archives/12/src/utils.h b/archives/12/src/utils.h new file mode 100644 index 0000000..d785fa2 --- /dev/null +++ b/archives/12/src/utils.h @@ -0,0 +1,7 @@ +#define true 1 +#define false 0 +#define boolean char +struct String{ + int length; + char*str; +}; \ No newline at end of file diff --git a/current b/current index 9eff57eafdc4687f71714f66fff202537eab672c..d5a5c9d435272e8662ffeda23ebeb32199577e32 100755 GIT binary patch delta 2105 zcmZ`)eQZ-z6u!tE)^3iiTMImWBZMyI|rf9LC- zbI-Zw-j4Lsukmap$!yHxBb({nS!-bOa6c1x0!Zo}!E=@(ebmLBrQ5B@C1V;3fcv|L|tQkX#?2_Y?xh*X%F6f%lD zAu=}93gYo|6Qgy}jV6I+lFGUCfA5w+rb;_X>6egXFyGxrNwI#v7M%6W=-T3vHU zynP@2qCL}(kx*49Odt5T?_f5IVc#f8G-nmV_&Lm$&c$|@Va@#DIw8~P4SD-=BD`H(HEleyUpT2#Q_vQzqV{#;zL;1VvC4~eYIQ7-c$B!f8K zL^%f)WeYd-Af?@N*^U(Akb`wTCNDzSJ2=*3(2Iyfm}`5RSuw}Ve3zGlJ&(;tKF49X z31`ZdTe3*{aX;V<6ez8W(=o=XUls!66+Am)M=Si?Dv%`1R(R+HxP3hBgeISd9)S)Y z&nC62pkGlJob-9vv`Jkimq`AWz-8ZBYJqaz!(@%Hir+y~Fv@$zF7Ymk{%-o6G>fyt zU?mpZmy<5R*bufy0e9!_8BTGi?a5dly=x>)APMr-{uy*cI zi7t0wI?+lerW37n7@Q;pUC1RNUilgw1X|^EPdr+8Tqd78BfmQksN!+mRJ6x`)r8H|Svo z?Qk@>nC^tr!5RjOa0i)H;0-xx2dob{P5bfUa4^agz`BqTj)V%!hf%^3JXTKiWYioU zL%AJO4y<9nW@Z`_S^OHAQ|SMC2X@sv}7XC6|RByupcgkZEzxN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zITf)Z5kWOFltz=4Y%;DQx#Vs%nUj!C+shb94(lu&PQaS992-tLIvP^PP_fYzj5+Fv zu8QDN7)5%^_4Hp-?xeVcagTP2oa2PbbAj%*Wu;EK65v@}^yR!K)IguR$oX4%{QIF> ze}_K*3FY4}-9_$?!sFjG-THEV6l#c|re6I!!T%f1^5VZd?+BIg^_Qvv@?kXitRnhyz7;CluJ|u1=l?)mT4 z9YXsgU>pP)kjMPHsvg!YP{ zrrz;?<*largestProd) { - *largestProd=product; - printf("Largest product is now %d\n",*largestProd); - } -} +https://projecteuler.net/problem=12 +*/ int main(int argc,char**argv) { - - int GRID[]={8,2,22,97,38,15,0,40,0,75,4,5,7,78,52,12,50,77,91,8,49,49,99,40,17,81,18,57,60,87,17,40,98,43,69,48,4,56,62,0,81,49,31,73,55,79,14,29,93,71,40,67,53,88,30,3,49,13,36,65,52,70,95,23,4,60,11,42,69,24,68,56,1,32,56,71,37,2,36,91,22,31,16,71,51,67,63,89,41,92,36,54,22,40,40,28,66,33,13,80,24,47,32,60,99,3,45,2,44,75,33,53,78,36,84,20,35,17,12,50,32,98,81,28,64,23,67,10,26,38,40,67,59,54,70,66,18,38,64,70,67,26,20,68,2,62,12,20,95,63,94,39,63,8,40,91,66,49,94,21,24,55,58,5,66,73,99,26,97,17,78,78,96,83,14,88,34,89,63,72,21,36,23,9,75,0,76,44,20,45,35,14,0,61,33,97,34,31,33,95,78,17,53,28,22,75,31,67,15,94,3,80,4,62,16,14,9,53,56,92,16,39,5,42,96,35,31,47,55,58,88,24,0,17,54,24,36,29,85,57,86,56,0,48,35,71,89,7,5,44,44,37,44,60,21,58,51,54,17,58,19,80,81,68,5,94,47,69,28,73,92,13,86,52,17,77,4,89,55,40,4,52,8,83,97,35,99,16,7,97,57,32,16,26,26,79,33,27,98,66,88,36,68,87,57,62,20,72,3,46,33,67,46,55,12,32,63,93,53,69,4,42,16,73,38,25,39,11,24,94,72,18,8,46,29,32,40,62,76,36,20,69,36,41,72,30,23,88,34,62,99,69,82,67,59,85,74,4,36,16,20,73,35,29,78,31,90,1,74,31,49,71,48,86,81,16,23,57,5,54,1,70,54,71,83,51,54,69,16,92,33,48,61,43,52,1,89,19,67,48,}; - - int largestProd=0; - for (int i=0;i<400;i++) { - int x=i%20; - int y=i/20; - //Up - if (y>=3) { - checkForProduct(&largestProd,GRID[(y-3)*20+x]*GRID[(y-2)*20+x]*GRID[(y-1)*20+x]*GRID[i]); - } - //Right - if (x<=16) { - checkForProduct(&largestProd,GRID[(y)*20+x+1]*GRID[(y)*20+x+2]*GRID[(y)*20+x+3]*GRID[i]); - } - //Left - if (x>=3) { - checkForProduct(&largestProd,GRID[(y)*20+x-1]*GRID[(y)*20+x-2]*GRID[(y)*20+x-3]*GRID[i]); - } - //Down - if (y<=16) { - checkForProduct(&largestProd,GRID[(y+1)*20+x]*GRID[(y+2)*20+x]*GRID[(y+3)*20+x]*GRID[i]); - } - //Up-Left - if (y>=3&&x>=3) { - checkForProduct(&largestProd,GRID[(y-3)*20+x-3]*GRID[(y-2)*20+x-2]*GRID[(y-1)*20+x-1]*GRID[i]); - } - //Up-Right - if (y>=3&&x<=16) { - checkForProduct(&largestProd,GRID[(y-1)*20+x+1]*GRID[(y-2)*20+x+2]*GRID[(y-3)*20+x+3]*GRID[i]); - } - //Down-Left - if (x>=3&&y<=16) { - checkForProduct(&largestProd,GRID[(y+1)*20+x-1]*GRID[(y+2)*20+x-2]*GRID[(y+3)*20+x-3]*GRID[i]); - } - //Down-Right - if (y<=16&&x<=16) { - checkForProduct(&largestProd,GRID[(y+1)*20+x+1]*GRID[(y+2)*20+x+2]*GRID[(y+3)*20+x+3]*GRID[i]); - } + int counter=1; + long sum=0; + while (true) { + sum+=counter; + printf("Checking %ld...\n",sum); + int current=1; + int max=sum; + int divisorCount=0; + while (current500) { + printf("\n\nNumber %ld has %d divisors!",sum,divisorCount); + return 0; + } + counter++; } - - printf("Highest product is %d",largestProd); - return 0; } \ No newline at end of file