From a381655b12e42a28c721025c489682974f377d86 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Sun, 24 Jul 2022 12:53:12 -0500 Subject: [PATCH] Coin amt code started Co-authored-by: sigonasr2 --- current | Bin 20656 -> 20688 bytes src/main.c | 119 +++++++++++++++++++++++++++++++++++++++-------------- 2 files changed, 89 insertions(+), 30 deletions(-) diff --git a/current b/current index e8919b51844b5a82b5709ceb87258a2a8010f066..ffd788120a22a5b08d1676b297ac2da7498fec51 100755 GIT binary patch delta 3094 zcmb_eeM}tJ5r1#*i^C9Z&yc;tz}yR8Pt?LwO?3ly`R70ak z!I%;nUk;SBC$UHrw?}IwK}sU5ilsM^0b!S!>s8N-c=g zSCM1TG#!ae(D3d`uZCU+ zR}Gu!7FaS!FkWkf+lEXkF^%@aXGV#Zs&bS1JjX21Qm=V=Rok1YEnIG-`EWtVgrAxo zH6QdI@AU41PfYnBnnHbq2>3H#Y9k_5HTGo17|1?EKC>jVy*-_vR|~hjbNVdKw1GUq z^`7i@D~r~HIwO7RQ#6&#@iiXdldal~I2ebQ&HJ5vtySm6Chb3LB~u~YB0-uZ4P@jJ zOIrFkA7%d#;24e`MeC(iRx_NlNKQR5i#5G!)S3_r{*ZFUmY?#=GD2=Cg~ws5?TMWz z96&w8RZYl0GxEMe{rl2;^*d|yg;E%^?S_q_6n+EOPRUB3!|lV~4A-+PDUpYR*U%yl zn?7am;Bt4C95tO~^5CUzt1_42I?4P#`s%T!5UQNul}GY^KFWvTs8&aTQR>c(tCHH_parspG8A=<>Aah79R^(&Lt#j z6yyDzyniv!$QyJtWGZ|zhix}LOY-3S-MDQIdDmy3QZG&`B9ivtC$MS zahzv}#mb9JC7E^px8EzuRA`dPHwvPmNqHn%Jvbe?jDCjIe!oJ$ zfzTu!=$*8j`0EF3%H}K4Cfs;Cv19#%M*4c9L%Kz2IkYSLe#UPMXMe6J9^}o)KIC1 zPaqE>4WMtmC)k7f(mi&Olf0Dtl4=PqIm4`41*ZBb9XjVSIwUj94!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i_>Q4Q z7d(6v7WBKb4;FPEF4{sm0{fm&rP_wN>g|sg7ZsPnHw^AR3_!r24ujGY14>lU*{C*( z%#TrInRj6ipZWo2UQZ$@vqo|42qJ$oBqI<=Bk1We=PoMtI&y{U-S&Wy?fFO430aTt zkiV4_g}@THN*0;9O<+*flBK9i0$om!bWHIE^Dh zjA_z@7-#DJPjDC#V_|VdqYxLAsUbGiJOj7Bvc}LnHzdx$rQDT$Gy6^dxREdwG|%mq zOwUavOlHG#IfU#tnxOPmIBVNWL#q!#Vz9rSsoN;C_e30@n-L(->_uOz6ni^LDSFi+!Al(b=a&u?`YIF1GbmU;Jj|w{1uVg1)d6YxjMTKy1Lq1yIfBm>2B@lbOpLPU5C04?tAi?To#np zGAg|!ucOU~%Z?62-J#It9<>nWK?P*Cm zH%(1WA^AwXh5aJj^Q|?oC)x*T#ZJQ)D2;&+B^R#R0?jDZpfnE8qSTJkr*O77J1K-x z_CvT_Y&Tp$aSz1!xWN9e|r%kXv7<@2*E%0F~CsWf(gvZm=HFjD5UkX0&cQ-Sor z$7N3151*BJ1hWAO${qAB)RlWIA$}k!IYQ$L5H5FGy!^Y#fdpZ^yeZerP9|(v))cO_7T-gV~S}O3Bi1oRk-eeWz~o1`|xbF)3)5M8g=Sa zWEoG#osYs;bs=o7Ug3L*F#-n26Q)HgcV!}$V->g^2`NC)S8 z-70aM^PR|B1RGiEzYlpAArKKP^cA3@m0pb4#FKP6-Xkg>xiY-5V;juvco$wX*du?c z?WK{%x+f_8Dva&)Sj+}>6AkaeJhE}lYG?;vy(dSjQVm;pe5{rQI99*P806Ux!bp9| zVy$a6e*xy}`>-mHGvBomzU20nj@F-ugrci@P>gx-J=|JwfoQM;PI diff --git a/src/main.c b/src/main.c index 07e3a2c..9902813 100644 --- a/src/main.c +++ b/src/main.c @@ -1,49 +1,108 @@ #include #include "utils.h" -#include /* - Surprisingly there are only three numbers that can be written as the sum of fourth powers of their digits: + In the United Kingdom the currency is made up of pound (£) and pence (p). There are eight coins in general circulation: - 1634 = 14 + 64 + 34 + 44 - 8208 = 84 + 24 + 04 + 84 - 9474 = 94 + 44 + 74 + 44 + 1p, 2p, 5p, 10p, 20p, 50p, £1 (100p), and £2 (200p). - As 1 = 14 is not a sum it is not included. + It is possible to make £2 in the following way: - The sum of these numbers is 1634 + 8208 + 9474 = 19316. + 1×£1 + 1×50p + 2×20p + 1×5p + 1×2p + 3×1p - Find the sum of all the numbers that can be written as the sum of fifth powers of their digits. + How many different ways can £2 be made using any number of coins? - https://projecteuler.net/problem=30 + https://projecteuler.net/problem=31 */ +enum Currency{ + pence1, + pence2, + pence5, + pence10, + pence20, + pence50, + pound1, //100 pences + pound2, //200 pences +}; + +int combinationCount(enum Currency cur) { + switch (cur) { + case pence1:{ + return 1; + }break; + case pence2:{ + return 2; //2 + }break; + case pence5:{ + return 5; //3 + }break; + case pence10:{ + return 10; //4 + }break; + case pence20:{ + return 20; + }break; + case pence50:{ + return 50; + }break; + case pound1:{ + return 100; + }break; + case pound2:{ + return 200; + }break; + } +} + +int getValue(enum Currency cur) { + switch (cur) { + case pence1:{ + return 1; + }break; + case pence2:{ + return 2; + }break; + case pence5:{ + return 5; + }break; + case pence10:{ + return 10; + }break; + case pence20:{ + return 20; + }break; + case pence50:{ + return 50; + }break; + case pound1:{ + return 100; + }break; + case pound2:{ + return 200; + }break; + } +} + int main(int argc,char**argv) { - int counter=0; - int currentDigit=10; - long digitSum=0; - while (counter<10000000) { - int tempNumb=currentDigit; - digitSum=0; - long val=0; - while (tempNumb>0) { - int digit=tempNumb%10; - tempNumb/=10; - val=(long)pow(digit,5); - digitSum+=val; - if (digitSum>currentDigit) { - goto next; - } + int currencyAmts[8] = {200}; + int combinationCount=0; + int maxCurrencyVal=200; + int currentMarker=0; + int highestMarker=1; + + while (true) { + printf("Coin amts: "); + for (int i=0;i<8;i++) { + printf("%d ",currencyAmts[i]); } - if (digitSum==currentDigit) { - printf("%d has a digit sum that equals its number!\n",currentDigit); + printf("\n"); + while (true) { + currencyAmts[currentMarker] } - next: - currentDigit++; - counter++; + } - return 0; } \ No newline at end of file