Pay it up!

In Brilliantown the currency is the brill ( B \mathbb{B} .) There are four denominations in use : 1 B 1\space\mathbb{B} , 7 B 7\space\mathbb{B} , 23 B 23\space\mathbb{B} and 59 B 59\space\mathbb{B} banknotes.

How many ways are there to pay for 442 B 442\space\mathbb{B} ?


The answer is 2018.

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

Nicola Mignoni
Feb 20, 2018

We could consider all the ways to evaluate 442 442 using { 1 , 7 , 23 , 59 } \{1,7,23,59\} like

a + b 7 + c 23 + d 59 = 442 \displaystyle a+b\cdot 7+c \cdot 23 + d \cdot 59 =442

where

0 a 442 1 = 442 \displaystyle 0\leq a\leq \left \lfloor{\frac{442}{1}} \right \rfloor=442

0 b 442 7 = 63 \displaystyle 0\leq b\leq \left \lfloor{\frac{442}{7}} \right \rfloor=63

0 c 442 23 = 19 \displaystyle 0\leq c\leq \left \lfloor{\frac{442}{23}} \right \rfloor=19

0 d 442 59 = 7 \displaystyle 0\leq d\leq \left \lfloor{\frac{442}{59}} \right \rfloor=7 .

The right-side bound is the biggest coefficient such that I can multiplay a , b , c a,b,c or d d before finding a number greater than 442 442 . Let's use a simple MATLAB code to evaluate all the possible occurrences:

3703517 iteration, seems like lots of computation there.

Aldiputera Laksamana - 3 years, 2 months ago

RationalQ = Simplify [ $#$1 Q ] & ; \text{RationalQ}=\text{Simplify}[\text{\$\#\$1}\in \mathbb{Q}]\&;

change ( amount$_$/;RationalQ ( amount ) amount 0 , currency$__$/; Head [ currency ] = List AllTrue [ currency , RationalQ ] AllTrue [ currency , Positive ] ) := Block [ { c , a , s } , c ( 0 , _ ) := 1 ; c ( a$_$ , _ ) := 0 /; a < 0 ; c ( a$_$ , { } ) := 0 /; a 0 ; c ( a$_$ , s$_$ ) := c ( a , s ) = c ( a First [ s ] , s ) + c ( a , Rest [ s ] ) ; c ( amount , Sort [ Union [ currency ] , Greater ] ) ] ; \text{change}( \\ \text{amount\$\_\$}\text{/;}\text{RationalQ}(\text{amount})\land \text{amount}\geq 0, \\ \text{currency\$\_\_\$}\text{/;} \\ \text{Head}[\text{currency}]=\text{List}\land \\ \text{AllTrue}[\text{currency},\text{RationalQ}]\land \\ \text{AllTrue}[\text{currency},\text{Positive}])\text{:=} \\ \text{Block}[\{c,a,s\}, \\ c(0,\_)\text{:=}1; \\ c(\text{a\$\_\$},\_)\text{:=}0\text{/;}a<0; \\ c(\text{a\$\_\$},\{\})\text{:=}0\text{/;}a\neq 0; \\ c(\text{a\$\_\$},\text{s\$\_\$})\text{:=}c(a,s)=c(a-\text{First}[s],s)+c(a,\text{Rest}[s]); \\ c(\text{amount},\text{Sort}[\text{Union}[\text{currency}],\text{Greater}])];

change ( 442 , { 59 , 23 , 7 , 1 } ) 2018 \text{change}(442,\{59,23,7,1\}) \Longrightarrow 2018

Mark Hennings
Jan 27, 2018

a = 0 7 b = 0 1 23 ( 442 59 a ) ( 1 + 1 7 ( 442 59 a 23 b ) ) = 2018 \sum_{a=0}^7 \sum_{b=0}^{\lfloor\frac{1}{23}(442 - 59a)\rfloor}\left(1 + \big\lfloor \tfrac17(442 - 59a - 23b)\big\rfloor\right) \; = \; \boxed{2018} counts the number of ways of paying with a × 59 B a \times 59\mathbb{B} , b × 23 B b \times 23\mathbb{B} , c × 7 B c \times 7\mathbb{B} , with the rest in singles.

How did you compute the sum?

Agnishom Chattopadhyay - 3 years, 4 months ago

Log in to reply

It can be computed by using two for loops. Actually, I think this approach works well for 4 kinds of banknotes. A

Heshu Wang - 3 years, 4 months ago

Log in to reply

For this coin change problem, an alternative solution could be using dynamic programming.

Heshu Wang - 3 years, 4 months ago

Can you elaborate, how did you arrive at this sum?

Kunal Gupta - 3 years, 4 months ago

Log in to reply

I used a computer.

Mark Hennings - 3 years, 4 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...