Payng with cash - part II

With plenty of pennies, nickels, dimes, quarters and singles ($1 bills) in my pockets I can buy a cup of coffee for $1.50 in any possible way. In how many different ways a cup of coffee can be bought with the exact amount of money ($1.50)?


The answer is 729.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

3 solutions

Mark Hennings
Dec 1, 2018

I can choose to use 0 s 1 0 \le s \le 1 singles. If I use s s singles, I need to make up the balance of 150 100 s 150-100s cents out of quarters, dimes, nickels and pennies, and so I can use q q quarters, where 0 q 6 4 s 0 \le q \le 6 - 4s . I then have to make the up the balance of 150 100 s 25 q 150-100s -25q cents out of dimes, nickels and pennies, and so I can use d d dimes, where 0 d 15 10 s 5 2 q 0 \le d \le \lfloor15-10s-\tfrac52q\rfloor . I can then choose to use n n nickels, where 0 n 30 20 s 5 q 2 d 0 \le n \le 30 - 20s - 5q - 2d , and then make up the difference in pennies. Thus the number of methods of paying is N = s = 0 1 q = 0 6 4 s d = 0 15 10 s 5 2 q ( 31 20 s 5 q 2 d ) = 729 N \; = \; \sum_{s=0}^1 \sum_{q=0}^{6-4s} \sum_{d=0}^{\lfloor 15 - 10s - \frac52q\rfloor} (31 - 20s - 5q - 2d) \; = \; \boxed{729}

Brilliant solution. After writing my boring and very long solution, I came up with a shortcut formula similar to yours. It works with any amount of cents. I'll add it to my original solution.

A Former Brilliant Member - 2 years, 6 months ago

Hello Mr. Hennings. I know that it's to much to ask, but a person reported my solution on "Counting solutions - part II" . If you have time, please check my solution, because you're the expert in solving such problems. Thank you for your consideration.

A Former Brilliant Member - 2 years, 6 months ago

I m i s s e d 1 a n d g o t 728. M y a p p r o a c h . D i v i d e t h e p r o b l e m i n t o t w o m a i n g r o u p s a n d s u b g r o u p s . B . . . . . L e t s s t a n d f o r s i n g l e s a n d q s t a n d f o r Q u a r t e r s . a . s : b . q m e a n i n g a s i n g l e s a n d b Q u a r t e r s . a = 0 o r 1 , b = 0 t o 6. E v e r y s u b g r o u p o f B w i l l h a v e F I X s a n d q . A . . . . . i n s a m e w a y d f o r d i m e s , n f o r n i c k e l s , p f o r p e n n i e s . x . d x d i m e s , y . n : z . p y n i c k e l s a n d z p e n n i e s . T h e d i f f e r e n t w a y s t o g e t 150 c e n t s i n a n y s u b g r o u p i s f o u n d i n t h i s , a s p e r t h e t w o g i v e n f o r m u l a s . N T , d = x i s t h e n u m b e r o f w a y s t o g i v e T c e n t s i f d = x i n t h e g i v e n A g r o u p . S u b g r o u p s . B 0 = 0 c e n t s , B 25 = 25 c e n t s , B 50 = 50 c e n t s , B 75 = 75 c e n t s , I n t h e n e x t s u b g r o u p s , B K , L K c e n t s , i n c l u d e s L s i n g l e , L = 0 o r 1. e . g . B 150 , 1 = 150 = 1. s : 2. q . B 100 , 0 o r B 100 , 1 = 100 c e n t s , B 125 , 0 o r B 125 , 1 = 125 c e n t s , B 150 , 0 o r B 150 , 1 = 150 c e n t s . A 0 = 0 c e n t s , A 25 = 25 c e n t s , A 50 = 50 c e n t s , A 75 = 75 c e n t s , A 100 = 100 c e n t s , A 125 = 125 c e n t s , A 150 = 150 c e n t s . L e t N u m b e r o f w a y s = M e v e n = ( c e n t s r e q u i r e d f o r g i v e n A s u b g r o u p , w h e n e v e n 10 + 1 ) 2 . A n d N u m b e r o f w a y s = M o d d = ( ( c e n t s r e q u i r e d f o r g i v e n A s u b g r o u p w h e n o d d ) + 5 10 ) 2 + c e n t s r e q u i r e d f o r g i v e n A s u b g r o u p + 5 10 . W a y s f o r B 0 + A 150 = ( 150 10 + 1 ) 2 = 256. W a y s f o r B 2 5 + A 125 = ( 125 + 5 10 ) 2 + 13 = 182. W a y s f o r B 5 0 + A 100 = ( 100 10 + 1 ) 2 = 121. W a y s f o r B 7 5 + A 75 = ( 75 + 5 10 ) 2 + 8 = 72. W a y s f o r B 100 , 0 + A 50 = ( 50 10 + 1 ) 2 = 36. W a y s f o r B 100 , 1 + A 50 = ( 50 10 + 1 ) 2 = 36. W a y s f o r B 125 , 0 + A 25 = ( 25 + 5 10 ) 2 + 3 = 12. W a y s f o r B 125 , 1 + A 25 = ( 25 + 5 10 ) 2 + 3 = 12. W a y s f o r B 150 , 0 + A 0 = ( 0 10 + 1 ) 2 = 1. W a y s f o r B 150 , 1 + A 0 = ( 0 10 + 1 ) 2 = 1. 256 + 182 + 121 + 72 + 36 + 36 + 12 + 12 + 1 + 1 = 729. I~ missed~~1~and~got~ 728.\\ My~ approach. \\ ~~\\ \color{#3D99F6}{Divide~ the~ problem~ into~ two ~main ~groups~ and ~sub~ groups. \\ B.....Let~s~stand~for~singles~~and~~q~stand~for~Quarters.\\ ~~~~~a.s:b.q~meaning~'a'~singles~and~'b'~Quarters.~~a=0~or~1,~~~~b=0~to~6. \\ ~~~~~Every~sub~group~of~B~~will~have~FIX~s~and~q.\\ A.....in~same~way~d~for~dimes,~~~n~for~nickels,~~~p~for~pennies.\\ ~~~~~x.d\implies ~x~dimes,~~~~y.n:z.p\implies~y~nickels~and~z~pennies. \\ ~~~~~The~different~ways~to~get~150 cents~in~any~subgroup~is~found~in~this,~as~per~the~two~given~formulas.\\ N_{T,d=x}~~~~ is~the~number~of~ways~to~give~T cents~if~d=x~in~the~given~A~group.\\ ~~~~\\ ~~\\ \Large {Subgroups}.\\ B_0=0 cents,~~B_{25}=25 cents,~~B_{50}=50 cents,~~B_{75}=75 cents,\\ ~~~In~the~next~sub~groups,~B_{K,L}~\implies~ {K cents, includes~L~single},~L=0~or~1.~e.g.~ B_{150,1}=150 =~1.s:2.q.\\ B_{100,0}~or~B_{100,1}=100 cents,~~B_{125,0}~or~B_{125,1}=125 cents, ~~~B_{150,0}~or~B_{150,1}=150 cents.\\ A_0=0 cents,~~A_{25}=25 cents,~~A_{50}=50 cents,~~A_{75}=75 cents,~~A_{100}=100 cents,~~A_{125}=125 cents,~~A_{150}=150 cents.\\ ~~\\ Let~Number~of~ways~=~M_{even}~\\ =\left (\dfrac{cents~required~for~given~A~subgroup,~when~even}{10}+1 \right )^2.\\ And~Number~of~ways~=~M_{odd}~\\ =\left (\dfrac{(cents~required~for~given~A~subgroup~when~odd)+5}{10} \right)^2+\dfrac{cents~required~for~given~A~subgroup+5}{10}.\\ ~~~~\\ Ways~for~B_0+A_{150}=\left (\dfrac{150}{10}+1 \right )^2=256.~~~~~~Ways~for~B_25+A_{125}=\left (\dfrac{125+5}{10}\right )^2+13=182.\\ Ways~for~B_50+A_{100}=\left (\dfrac{100}{10}+1 \right )^2=121.~~~~~Ways~for~B_75+A_{75}=\left (\dfrac{75+5}{10}\right )^2+8=72.\\ Ways~for~B_{100,0}+A_{50}=\left (\dfrac{50}{10}+1 \right )^2=36.~~~~Ways~for~B_{100,1}+A_{50}=\left (\dfrac{50}{10}+1 \right )^2=36.\\ Ways~for~B_{125,0}+A_{25}=\left (\dfrac{25+5}{10} \right )^2+3=12.~~Ways~for~B_{125,1}+A_{25}=\left (\dfrac{25+5}{10} \right )^2+3=12.\\ Ways~for~B_{150,0}+A_{0}=\left (\dfrac{0}{10}+1 \right )^2=1.~~~~~~~Ways~for~B_{150,1}+A_{0}=\left (\dfrac{0}{10}+1 \right )^2=1.\\ 256+182+121+72+36+36+12+12+1+1=\Huge \color{#D61F06}{729}. } B e l o w i s d e r i v a t i o n o f t h e t w o f o r m u l a s . Below~is~derivation~of~the~two~formulas.
W e u s e n o t a t i o n s a s a b o v e . W a y s f o r A 150 . x . d + y . n + z . p = 150. a n e v e n n u m b e r . 0. d y = 0 t o 30 ( n i c k e l s ) . . . . . . . 0. n : 150. p , 1. n : 125. p , 2. n : 140. p , 3. n : 135. p , . d : 4. n : 130. p , . . . 29. n : 5. p , : 30. n : 0. p . N 150 , d = 0 = 31 1. d y = 0 t o 28 ( n i c k e l s ) . . . . . . . 0. n : 140. p , 1. n : 135. p , 2. n : 130. p , 3. n : 125. p , . d : 4. n : 120. p , . . . 27. n : 5. p , : 28. n : 0. p . N 150 , d = 1 = 29 We~use~notations~as~above.\\ {\color{#3D99F6}{Ways~for~A_{150}} }.~~~~~~x.d+y.n+z.p=150.--an~even~number. \\ ~~~~\\ 0.d~~y=0~to~30~(nickels).......\\ 0.n:150.p,~~~1.n:125.p,~~~2.n:140.p,~~~3.n:135.p,~~~.d:4.n:130.p,~~~ . . . ~~~29.n:5.p,~~~:30.n:0.p.~~~~~~ N_{150,d=0}=31\\ ~\\ 1.d~~y=0~to~28~(nickels).......\\ 0.n:140.p,~~~1.n:135.p,~~~2.n:130.p,~~~3.n:125.p,~~~.d:4.n:120.p,~~~ . . . ~~~27.n:5.p,~~~:28.n:0.p.~~~~~~ N_{150,d=1}=29\\ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13. d y = 0 t o 4 ( n i c k e l s ) . . . . . . . 0. n : 20 p , 1. n : 15 p , 2. n : 10 p , . . . 4. n : 0 p . N 150 , d = 13 = 5 14. d y = 0 t o 4 ( n i c k e l s ) . . . . . . . 0. n : 10 p , 1. n : 5 p , 2. n : 0 p , N 150 , d = 13 = 3 ..........\\ ..........\\ ..........\\ 13.d~~y=0~to~4~(nickels).......\\ 0.n:20p,~~~1.n:15p,~~~2.n:10p,~~~ . . . ~~~4.n:0p.~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ N_{150,d=13}=5\\~~\\ 14.d~~y=0~to~4~(nickels).......\\ 0.n:10p,~~~1.n:5p,~~~2.n:0p,~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ N_{150,d=13}=3\\ ~~\\ 15. d y = 0 ( n i c k e l s ) . . . . . . . . 0. n : 0. p N 150 , d = 15 = 1 S o w e s e e t h a t t o g e t 150 c e n t s f r o m d , n , p w e h a v e 1 + 3 + 5 + . . . + 27 + 29 + 31 = ( 30 2 + 1 ) 2 = 256 w a y s . N o t e : 30 i s t h e n u m b e r o f n i c k e l s w e c a n h a v e i f o n l y n i c k e l s w e r e u s e d t o o b t a i n 150 c e n t s . 15.d~~y=0(nickels)........\\ 0.n:0.p~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ N_{150,d=15}=1\\ So~we~see~that~to~get~150 cents~from~d,n,p~~we~have~1+3+5+ . . .+27+29+31=\left (\dfrac{30} 2+1 \right )^2=\color{#3D99F6}{256~ways}.\\ Note:-30~is~the~number~of~nickels~we~can~have~if~only~nickels~were~used~to~obtain~150 cents. \\ O r i t i s ( c e n t s r e q u i r e d 5 ) . w h e n c e n t s r e q u i r e d a r e E V E N t h e n u m b e r w a y s = ( c e n t s r e q u i r e d 10 + 1 ) 2 Or~it~is\left (\dfrac{cents~required} 5 \right ). \implies~~~\color{#20A900}{when~cents~required~are~~EVEN~~~the~number~~ways=\left (\dfrac{cents~required} {10}+1 \right )^2 }\\ ~~\\ ~~\\ Applying~the~same~method.......\\ ~~\\ {\color{#3D99F6}{Ways~for~A_{125}}.~~~~~~x.d+y.n+z.p=125-an~odd~number.\\ ~~~~\\ 0. d y = 0 t o 25 ( n i c k e l s ) . . . . . . . 0. n : 125. p , 1. n : 120. p , 2. n : 115. p , 3. n : 110. p , 4. n : 105. p , . . . 24. n : 5. p , 25. n : 0. p . N 125 , d = 0 = 26 1. d y = 0 t o 23 ( n i c k e l s ) . . . . . . . 0. n : 115. p , 1. n : 110. p , 2. n : 105. p , 3. n : 100. p , 4. n : 95. p , . . . 22. n : 5. p , 23. n : 0. p . N 150 , d = 1 = 24 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10. d y = 0 t o 5 ( n i c k e l s ) . . . . . . . 0.d~~y=0~to~25~(nickels).......\\ 0.n:125.p,~~~1.n:120.p,~~~2.n:115.p,~~~3.n:110.p,~~~4.n:105.p,~~~ . . . ~~~24.n:5.p,~~~25.n:0.p.~~~~~~ N_{125,d=0}=26\\ ~\\ 1.d~~y=0~to~23~(nickels).......\\ 0.n:115.p,~~~1.n:110.p,~~~2.n:105.p,~~~3.n:100.p,~~~4.n:95.p,~~~ . . . ~~~22.n:5.p,~~~23.n:0.p.~~~~~~ N_{150,d=1}=24\\ ..........\\ ..........\\ ..........\\ 10.d~~y=0~to~5~(nickels).......\\ 0. n : 25 p , 1. n : 20 p , 2. n : 15 p , . . . 4. n : 5 p 5 n : 0. p N 125 , d = 10 = 6 11. d y = 0 t o 3 ( n i c k e l s ) . . . . . . . 0. n : 15 p , 1. n : 10 p , 2. n : 5 , N 125 , d = 11 = 4 12. d y = 0 ( n i c k e l s ) . . . . . . . . 0. n : 5. p 1. n : 0 p N 125 , d = 12 = 2 0.n:25p,~~~1.n:20p,~~~2.n:15p,~~~ . . . ~~~4.n:5p~~~5n:0.p~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ N_{125,d=10}=6\\~~\\ 11.d~~y=0~to~3~(nickels).......\\ 0.n:15p,~~~1.n:10p,~~~2.n:5,~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ N_{125,d=11}=4\\ ~~\\ 12.d~~y=0(nickels)........\\ 0.n:5.p~~~1.n:0p~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ N_{125,d=12}=2\\ S o w e s e e t h a t t o g e t 125 c e n t s f r o m d , n , p w e h a v e 2 + 4 + 6 + 8 + 10 + 12 + 14 + . . . + 22 + 24 + 26 = 2 ( 1 + 2 + 3 + 4 + 5 + 6 + 7 + . . . + 11 + 12 + 13 ) = 2 13 14 2 = 1 3 2 + 13 So~we~see~that~to~get~125 cents~from~d,n,p~~we~have\\ 2+4+6+8+10+12+14+ . . . +22+24+26=2*(1+2+3+4+5+6+7+ . . . +11+12+13)\\ =2*\dfrac{13*14} 2=13^2+13\\ = ( 25 + 1 2 ) 2 + ( 25 + 1 2 ) . W h e n t h e c e n t s r e q u i r e d i s O D D , n u m b e r o f w a y s w e c a n u s e d , n a n d p . = ( c e n t s r e q u i r e d + 5 10 ) 2 + ( c e n t s r e q u i r e d + 5 10 ) . =\left(\dfrac{25+1} 2\right )^2+\left(\dfrac{25+1} 2\right ).\\ \implies~\color{#20A900}{When~the~cents~required~is~ODD,~number~of~ways~we~can~use~d,n~and~p.\\ = \left (\dfrac{cents~required+5}{10} \right )^2+\left (\dfrac{cents~required+5}{10} \right ) }.\\

Niranjan Khanderia - 2 years, 5 months ago

This algorithm can be done in any programming language that supports recursion. It helps if the language also supports memorization of previously computed results.

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...