Exoplanet tickets

In a small, remote country, there are only two types of bills--the $X bill and the $Y bill.

With combinations of these bills, almost all positive integer prices can be paid exactly. Only fifteen positive integer prices can't be paid exactly, one of which is $18.

What is X + Y ? X+Y?


The answer is 15.

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.

4 solutions

Kevin Guo
May 21, 2017

Relevant wiki: Postage Stamp Problem / Chicken McNugget Theorem

In this case, we can use the Chicken McNugget Theorem . Basically, if you can purchase items at m and n dollars, then the greatest price which cannot be bought using m and n (or be expressed in the form am+bn) is mn-m-n. Colloquially, there are ( m 1 ) ( n 1 ) 2 \frac{(m-1)(n-1)}{2} integers not expressed as am + bn. Therefore,

(X-1)(Y-1)=30

Using factors of 30, we get possible solutions of (2,31) (3,16) (4,11) (6,7)

Of these solutions, only (4,11) cannot express $18. Therefore, X+Y = 4 + 11 or $15 .

Link for more information is here .

Nice way to solve it! One small thing, when stating Chicken McNugget Theorem, we should say "m and n are relatively prime", right?

Wei Chen - 4 years ago

Log in to reply

Yes, you're right.

Pi Han Goh - 3 years, 3 months ago

Curious mind wants to know Why (X-1)(Y-1)=30?

Kamaljot Singh - 4 years ago

Log in to reply

The problem states that 15 integers cannot be expressed by the linear combination of X and Y. Using the Chicken McNugget Theorem, we know that ( X 1 ) ( Y 1 ) 2 \frac{(X-1)(Y-1)}{2} thus equals 15, or that (X-1)(Y-1) = 30.

Arne Degrande - 4 years ago

I understand that this problem is based on the buyer having exact change without respect to the seller giving anything back, but I am still confused here. On a quick look, 4 and 11 seem to have greater than 15 integers that cannot be paid exactly using only additive arithmetic (1,2,3,5,6,7,9,10,13,14,17,18,21,25,28,29--at least). I am coming off 4 12-hour nightshifts so I could be making a simple math error. Where am I going wrong?

Stephen Garinger - 4 years ago

Log in to reply

28=7x4, so it can be paid by 7 of $4 bills. After 29, we can show 4 consecutive integers of 30,31,32 and 33 can all be expressed as 4a+11b, after that we just keep adding 4s to get all other integers.

Wei Chen - 4 years ago

Log in to reply

Thanks. Had a nap and brain is working a bit better!

Stephen Garinger - 4 years ago

To exhaustively list all the values in our 'miss' set, I considered the positive integers mod 4, moving up in each of the three sets (0 mod 4 ignored) until reaching a multiple of 11:

1 mod 4: {1,5,9,13,17,21,25,29} - 8 total

2 mod 4: {2,6,10,14,18} - 5 total

3 mod 4: {3,7} - 2 total

Richard Desper - 4 years ago

Why can't it be 17? Bills of 10 and 7. No matter how you combine them, it can never sum up 18.

Victor Shirosaki - 4 years ago

Log in to reply

Because the question says that.. "Only fifteen integer prices can't be paid exactly"... and there are many more than 15 integers you can't get with 10 and 7

Keith Brown - 4 years ago

Is the only way to solve it using the Chicken McNugget Theorem?

Margaret Brunt - 4 years ago

Log in to reply

No, that theorem is the crux in solving this question.

Pi Han Goh - 4 years ago

Confused by problem wording. "No need for overpayment or dispute over underpayment" doesn't preclude the possibility of making change. I could pay 18 eleven bills and receive 45 four bills in change. Pay 198 get 180 back I paid 18 without an overpayment or underpayment.

Jon Michael Cherney - 4 years ago

Log in to reply

I think you're referring to the previous phrasing. The previous phrasing essentially states that you must pay the exact amount without paying more or less.

Pi Han Goh - 4 years ago

There is something about this question and the answer that I don't understand at all. I calculate that there are a total of 21 integers that cannot be paid with only $8 and $7 dollar bills. The total list of unpayable amounts is. 1,2,3,4,5,6,9,10,11,12,13,17,18,19,20,25,26,27,33,34,41. any integer value above 41 can be paid .

Can anyone demonstrate how to pay any of these 21 integer values with only $7 and $8 dollar bills?

Now! If the two bill where $ 7 and $5 dollars I calculate that there are only 12 integer values that cannot be paid. That list is 1,2,3,4,6,8,9,11,13,16,18,23. In this case any integer value above 23 can be paid.

What am I missing hear?

Darryl Dennis - 4 years ago

Log in to reply

the 2 bills are 4 and 11, not 7 and 8.

Can anyone demonstrate how to pay any of these 21 integer values with only $7 and $8 dollar bills?

No, it's not possible. You have correctly shown the list of all the 21 numbers (1, 2, 3, ... , 41) are not possible.

What am I missing hear?

Like I said, the two bills should be (4 and 11), not (7 and 8), not (5 and 7) either.

Pi Han Goh - 4 years ago

Can anyone please add a proof to this theorum?

Manan Maheshwari - 4 years ago

This can be solved using the process of elimination. 1 to 3 can build 18 so are not candidates. Number 4 in combination might work however

4, 5 5+5+4+4 is 18 4, 6 6+6+6 is 18 4, 7 7+7+4 is 18 4, 8 only produce products of 4 so eliminated 4, 9 9+9 is 18 so 4, 10 4+4+10 is 18 so out 4, 11 is the first logical candidate which indeed works and produces all but the 15.

So focusing on the 18 rather than the 15 is more cost effective using a POE.

Larry R - 4 years ago

Can't I pay 18 by giving him six bills of 11 and get back 12 bills of 4 as a change, as 6(11-2*4) =18, right?

Yash Ghaghada - 4 years ago

I found the formula (m-1)(n-1)/2 by a different method. My method was not via a rigorous proof but it gave me enough confidence to seek for an answer of the form (X-1)(Y-1)=30. Having found 4 and 11 as a possible solution I checked and it worked.

So here's my thought processes which led to the formula. First I realised that every integer =mn or greater could be expressed as am+bn. 'Proof': the sequence m, 2m, 3m ... (n-1)m (all modulo n) must contain every number between 1 and n-1 without duplication. Taking k such that 0 < k < n then am = k (modulo n) so am = bn+k for some positive integers a and b. Hence k=am-bn. Therefore mn+k can be expressed as am+(m-b)n. Note that b<m (since a<n so bn < bn+k <nm) and hence both a and (m-b) are positive integers. This provides a solution for mn+1 up to mn+n-1. (m+1)n is simply a multiple of n and the next (n-1) numbers can be obtained by repeating the above trick. And so on indefinitely.

So all the inexpressible integers must be less than mn. Next I decided to count all the expressible integers from 0 to 2mn inclusive. At least, expressible in a restricted way. That is, I considered all integers of the form am+bn where a ranges from 0 to n and b ranges from 0 to m. The smallest this can be is zero. The largest it can be is 2mn. I satisfied myself [proof omitted] that each couple [a, b] led to a different sum with one exception: a=0, b=m gives the same result as a=n, b=0. Therefore the (m+1)(n+1) combinations produce (m+1)(n+1)-1 different expressible integers between 0 and 2mn inclusive, and hence the number of inexpressible integers (restricted to a<=n and b<=n) is (2mn+1) - (m+1)(n+1) +1 which simplifies to (m-1)(n-1).

Finally, the non-rigorous intuitive bit. I felt in my bones that the pattern created by generating integers of the form am+bn (with a=0 to n and b=0 to m) would be symmetrical around the midpoint mn. Hence the number of inexpressible integers less than mn would be (m-1)(n-1)/2. The other half (between mn and 2mn) are only inexpressible in my restricted sense. They can be expressed as am+bn where either a>n or b>m.

Paul Cockburn - 2 years, 8 months ago
George Jemmott
May 27, 2017
  • At least one of X or Y must be odd, or else all odd numbers "can't be paid exactly."
  • 1 does not work as X or Y, as then all integer prices can be paid exactly.
  • (At this point, Meghan Leffert's comment about factoring would have saved me some time, but I would have missed an interesting pattern) Starting with 2, I start searching for patterns:
X Y can't pay evenly: number of prices that can't be paid evenly:
2 3 1 1
2 5 1,3 2
2 7 1,3,5 3
2 9 1,3,5,7 4
2 2n+1 n
2 31 15

So X+Y = 33, right? It seems I missed the line, "one of which is $18."

  • 2 doesn't work as X or Y because it's a factor of 18, so neither will 3, 6, or 9.
  • Let's try 4 and various odd numbers. After the first two pairs, I think I see a pattern that will get the last column to 15 on the 4th pair. Rather than solving the fourth row, I decided to solve the third row, in order to confirm the linear pattern exists:
4 5 1,2,3,6,7,11 6
4 7 1,2,3,5,6,9,10,13,17 9
4 9 1,2,3,5,6,7,10,11,14,15,19,23 12
4 2*n/3+1 n
4 11 15

While slow, using this pattern, and the meta-pattern (See Kevin Guo's solution) that anticipates the number of "prices that can't be paid exactly" (the right-most column) from the pair of numbers X & Y, one could solve the same question with a much larger number of "prices that can't be paid exactly." (e.g. 5,000) Kevin's solution is great if you know (or can look up) the formula; this method helps derive the formula.

Wonderful! You have nearly derived the chicken nuggets formula on your own!

Pi Han Goh - 4 years ago

Good insight about at least one being odd!

I first eliminated combinations that could result in 18. Used a little trial and error and intuition to find 4 and 11. That would have helped...

What does 2 times n divided by 3 plus one refer to though?

Larry R - 4 years ago
Meghan Lefferts
May 22, 2017

Factor 18, and you will get all the small integers that cannot be a part of the solution: (18,1) (9,2) (6,3)

So 1, 2, 3, 6, 9, and 18 are automatically ruled out. Starting at the next pair, 4 and 5, you can see that 5+5+4+4=18 which rules out both of those. The next pair is 7 and 8. 7+7=14, 7+8=15, and 8+8 =16, so there is no possible way to get 18 using this pair, and since adding 7+8=15, that is the answer to the problem.

I don't quite understand how you ruled out both 4 and 5 as possibilities. I can see that you can't use both, but why can't you use one of them?

Karina Summers - 4 years ago

Actually I don't think 7 and 8 would work. You proved that 18 can't be expressed as 7a+8b, but you didn't show it satisfies the other condition:"Only fifteen integer prices can't be paid exactly".

In fact, there are 21 integers that can't be expressed as 7a+8b, namely: 1,2,3,4,5,6,9,10,11,12,13,17,18,19,20,25,26,27,33,34,41. This can be verified by the Chicken Nuggets Theorem quoted by Kevin Guo, as 21 = (7-1)(8-1)/2.

Wei Chen - 4 years ago

This solution makes no sense. You assume that just because one pair fits one part of the criteria that this must be the answer, not bothering to check whether it fits the whole problem and ignoring some 121 (this is based on your ruling out 1,2,3,6, and 9) other possible pairings. (7,8) is, in fact, wrong, because there are too many integers that can't be made.

Emily Namm - 4 years ago
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# https://brilliant.org/weekly-problems/2017-05-22/intermediate/?p=4
import numpy as np

def gcd(*numbers):
    """Return the greatest common divisor of the given integers"""
    from fractions import gcd
    return reduce(gcd, numbers)

match_val = 18
number_cant_be_paid = 15

for num1 in range(1,30):
    for num2 in range(num1+1,31):
        list_ = []
        if (num2%num1 == 0) or (gcd(*[num1,num2]) > 1):
            pass
        else:
            for i in range(75):
                for j in range(75):
                    x = num1*i+num2*j
                    if x not in list_:
                        list_.append(x)
            z = [i for i in range(max(list_))]
            y = np.array([i for i in z if i not in list_])
            non_mc_nugget = y[:np.argmax(np.diff(y))+1] 
            if (np.any(non_mc_nugget == match_val) and len(non_mc_nugget) == number_cant_be_paid):
                print """Denomination 1: %d 
Denomination 2: %d

List of all non-McNugget numbers for this problem: %s 
Total non-McNugget numbers in the list: %d""" \
%( num1, num2, list(non_mc_nugget), len(non_mc_nugget))

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
Answer:
Denomination 1: 4 
Denomination 2: 11

List of all non-McNugget numbers for this problem: [1, 2, 3, 5, 6, 7, 9, 10, 13, 14, 17, 18, 21, 25, 29] 
Total non-McNugget numbers in the list: 15



Also,
For a three bill scenario (with script modification), here are the two sets of denominations for fifteen positive integer prices can't be paid exactly, one of which is $18.
Denomination 1: 4
Denomination 2: 11
Denomination 3: 15
List of all non-McNugget numbers for this problem [1, 2, 3, 5, 6, 7, 9, 10, 13, 14, 17, 18, 21, 25, 29] 
Total non-McNugget numbers in the list 15


Denomination 1: 7
Denomination 2: 10
Denomination 3: 12
List of all non-McNugget numbers for this problem [1, 2, 3, 4, 5, 6, 8, 9, 11, 13, 15, 16, 18, 23, 25] 
Total non-McNugget numbers in the list 15


Additionally,
For a four bill scenario (with script modification), here are the nine sets of denominations for fifteen positive integer prices can't be paid exactly, one of which is $18.

Denomination 1: 7
Denomination 2: 10
Denomination 3: 12
Denomination 4: 17
List of all non-McNugget numbers for this problem [1, 2, 3, 4, 5, 6, 8, 9, 11, 13, 15, 16, 18, 23, 25] 
Total non-McNugget numbers in the list 15


Denomination 1: 7
Denomination 2: 10
Denomination 3: 13
Denomination 4: 16
List of all non-McNugget numbers for this problem [1, 2, 3, 4, 5, 6, 8, 9, 11, 12, 15, 18, 19, 22, 25] 
Total non-McNugget numbers in the list 15


Denomination 1: 7
Denomination 2: 12
Denomination 3: 13
Denomination 4: 17
List of all non-McNugget numbers for this problem [1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 15, 16, 18, 22, 23] 
Total non-McNugget numbers in the list 15


Denomination 1: 7
Denomination 2: 12
Denomination 3: 15
Denomination 4: 16
List of all non-McNugget numbers for this problem [1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 13, 17, 18, 20, 25] 
Total non-McNugget numbers in the list 15


Denomination 1: 8
Denomination 2: 11
Denomination 3: 12
Denomination 4: 14
List of all non-McNugget numbers for this problem [1, 2, 3, 4, 5, 6, 7, 9, 10, 13, 15, 17, 18, 21, 29] 
Total non-McNugget numbers in the list 15


Denomination 1: 8
Denomination 2: 11
Denomination 3: 12
Denomination 4: 17
List of all non-McNugget numbers for this problem [1, 2, 3, 4, 5, 6, 7, 9, 10, 13, 14, 15, 18, 21, 26] 
Total non-McNugget numbers in the list 15


Denomination 1: 8
Denomination 2: 11
Denomination 3: 13
Denomination 4: 15
List of all non-McNugget numbers for this problem [1, 2, 3, 4, 5, 6, 7, 9, 10, 12, 14, 17, 18, 20, 25] 
Total non-McNugget numbers in the list 15


Denomination 1: 8
Denomination 2: 11
Denomination 3: 14
Denomination 4: 15
List of all non-McNugget numbers for this problem [1, 2, 3, 4, 5, 6, 7, 9, 10, 12, 13, 17, 18, 20, 21] 
Total non-McNugget numbers in the list 15


Denomination 1: 8
Denomination 2: 12
Denomination 3: 13
Denomination 4: 15
List of all non-McNugget numbers for this problem [1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 14, 17, 18, 19, 22] 
Total non-McNugget numbers in the list 15 

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
def gcd(*numbers):
    """Return the greatest common divisor of the given integers"""
    from fractions import gcd
    return reduce(gcd, numbers)

match_val = 18
number_cant_be_paid = 15

for num1 in range(3,19):
    for num2 in range(num1+1,20):
        for num3 in range(num2+1,21):        
            list_ = []
            if (num2%num1 == 0) or (num3%num1 == 0) or (num3%num2 == 0) or \
               (gcd(*[num1,num2,num3]) > 1):
                pass
            else:
                for i in range(20):
                    for j in range(20):
                        for k in range(20):
                            x = num1*i+num2*j+num3*k
                            if x not in list_:
                                list_.append(x)
                z = [i for i in range(max(list_))]
                y = np.array([i for i in z if i not in list_])
                non_mc_nugget = y[:np.argmax(np.diff(y))+1] 
                if (np.any(non_mc_nugget == match_val) and \
                    len(non_mc_nugget) == number_cant_be_paid) and \
                    (np.max([num1,num2,num3])<match_val):
                    print """             
Denomination 1: %d
Denomination 2: %d
Denomination 3: %d
List of all non-McNugget numbers for this problem %s 
Total non-McNugget numbers in the list %d
""" %( num1, num2, num3, list(non_mc_nugget), len(non_mc_nugget))

Michael Fitzgerald - 3 years, 3 months ago

Below, is the script for three bills

Michael Fitzgerald - 3 years, 3 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...