Josh's Exam Cramming

Josh has only 10 days to cram for an olympiad. On each of these 10 days he practices exactly 1 topic of either algebra, combinatorics or number theory. However, he never practices algebra the day after he practices combinatorics, and he never practices combinatorics the day after he practices algebra. What are the last 3 digits of the number of ways that he can cram for these 10 days?


The answer is 119.

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.

6 solutions

Josh Rowley
Dec 27, 2013

After trying some early casework it becomes clear that this is not going to be particularly fruitful. However, a recurrence relationship seems possible. So let f(n) denote the number of possible sequences after n days. f(n) = Sequences with algebra in position n , sequences with combinatorics in position n and sequences with number theory in position n , a A a_{A} , a C a_{C} and a N a_{N} respectively. a A a_{A} = the number of sequences of length n-1 which have algebra or number theory on day n-1 , a C a_{C} = the number of sequences of length n-1 which have Combinatorics or number theory on day n-1 , a N a_{N} = the number of sequences of length n-1 which have algebra or combinatorics or number theory on day n-1 . Clearly a N a_{N} = f(n-1) . Also a A a_{A} + a C a_{C} = f(n-1) .+ f(n-2) . Therefore f(n) = 2 f(n-1) + f(n-2) . f(0) = 1 and f(1) = 3. Quicky building up this relation we get f(10) = 8119. So the last 3 digits are 119

I got the same sequence

2 , 4 , 10 , 24 , 58 , 140... 2,4,10,24,58,140... 👍👍

Vinay Sipani - 7 years ago

I am getting an answer 13858 in the following way: On the first day he has 3 choices, A,C or N. If he choose to study A or C on the first day, he has two choices each for A and C left for the next day (since A and C cannot come next to each other). If he chooses N on the first day, then he can choose any of the three on the next day. Working this way, I got a fractal tree kind of pattern, which initially branches into three (A,C and N). A and C branches to two each and N branches to three. In this way, after 10 steps the total number turns out to be the above. Where have I made mistake? Hope what I am trying to say is clear.

Log in to reply

Can you paste here the actual sequence you got? For example, what does your method give for 3 days instead of 10 10 ?

Snehal Shekatkar - 7 years ago
Andrea Gallese
May 25, 2014

Let's call

n n the lenght of the combination.

a n a_n the number of combination ending with Nuber Theory the nth day.

b n b_n the number of combination ending with Algebra or Combinatorics the nth day.

The n + 1 n+1 -th day, we have

1 1 combination ending with NT, every combination the previous day;

2 2 combination ending with Algebra or Combinatorics, every ending with NT the n n -th

1 1 combination ending with Algebra or Combinatorics, every combination that ends with either A or C., the n n -th day. So:

{ a n + 1 = a n + b n b n + 1 = 2 a n + b n \begin{cases} { a }_{ n+1 }={ a }_{ n }+{ b }_{ n } \\ { b }_{ n+1 }=2{ a }_{ n }+{ b }_{ n } \end{cases}

Computing, a 11 = 8119 { a }_{ 11 }=8119 . The answer is 119 \boxed { 119 }

your solution is most understandable here but i still confuse with the equation. From where did you got that, would you explain it with simpler(maybe the language)?

Hafizh Ahsan Permana - 6 years, 11 months ago

First, We formulate a function that generates all sequences of length n:

>>> def strings(n):
...     if n==1:
...             return ['A','B','C']
...     else:
...             newlist=[]
...             for i in strings(n-1):
...                     newlist.append('A'+i)
...                     newlist.append('B'+i)
...                     newlist.append('C'+i)
...             return newlist
...

Then, we count the number of strings in which we have AB or BA:

>>> d=0
>>> for i in strings(10):
...     if not (i.count('AB') or i.count('BA')):
...             d += 1
...

Let's ask for d

>>> d
8119
Nam Diện Lĩnh
Jun 23, 2015

The problem can be computed easily using recursion as below: (code written in Boo)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
mf={};
mg={};

def f(n as int, numtheo as bool) as int:
    if n<=1:
        return 1;

    if numtheo:
        if mf[n]==null:
            mf[n]=f(n-1, true)+2*f(n-1, false);
        return mf[n];

    if mg[n]==null:
        mg[n]=f(n-1, true)+f(n-1, false);
    return mg[n];

print f(11, true);

Krit Phuengphan
Jun 5, 2014

I got the recurrence relation for this problem, a n = 5 a n 2 + 2 a n 3 , a_{n}=5a_{n-2}+2a_{n-3} , where the initial conditions are a 1 = 3 , a 2 = 7 , a 3 = 17. a_{1}=3, a_{2}=7, a_{3}=17.

After that, I almost became crazy with finding the general solution! In addition, I failed at the the first try, then I cheated with using Wolfram Alpha. :\

Shashank Sistla
May 23, 2014

I couldn't figure out a fast way to do it, but I thought the long shot is the only way in my grasp, so, I made a sort of flowchart. This is not a long solution, but I decided to explain it elaborately.

So, I took A = Algebra, B = Number Theory, C = Combinatorics. Clearly, we can't have a sequence with either CA or AC in it. So let us arbitrarily begin said sequence with A. Notice that we can only follow by either A or C. So 2 ways are possible, till now.

A A C

Now, A again will yield two combinations, and C will yield three.

A A C A C A B C

And So on. To make my work simpler, I wrote down the number of ways each letter gives.

A will give 2 combinations, B and C, which give 2 or 3 respectively themselves. So on.

                                                                   A

                   2                                                                                                                3
  2                                      3                                                                      2                      2                  3

2 3 2 2 3 2 3 2 3 2 2 3

And so on. Note that each 2 gives rise to one 2 and one 3, and each 3 gives rise to two 2s and one 3.

I will re-write as:-

                                                                       A

                                II                                                                                      III

                              3 x II                                                                                 2 x III

                           7  x  II                                                                                  5 x III

Again, note that the sum of the co-efficients i.e. the number of 2's and 3's together, make up the number of 3's in the next step, as both 2 and 3 give rise to only one 3 in the next step.

On the other hand, as one 3 gives rise to two 2s, and one 2 gives rise to one 2, the number of 2s in the next step is equal to twice the (number of 3s + number of 2s)

If you continue my procces-ish flowchart.

          [1]                                                                  A

     [2]                     II                                                                                   III

     [3]                  3 x II                                                                             2 x III

     [4]                  7 x II                                                                             5  x III

     [5]                  17 x II                                                                           12 x III

    [6]                  41 x  II                                                                            29 x III

   [7]                   99 x II                                                                              70 x III

    [8]                 239 x II                                                                             169 x III

     [9]               577  x II                                                                               408 x III

     [10]             1393 x II                                                                             985 x III

Thus, if you start with A, there are 1393 + 985 = 2378 1393 + 985 = 2378 C, there are 1393 + 985 = 2378 1393 + 985 = 2378

For B, it's a bit different, work it out similarly, you get 3363 3363

Therefore, (2378 + 2378 + 3363 = 8119)\

Therefore \boxed{119} is the answer.

sighs It's actually a easy method, but my poor descriptive skills made me type an essay, nevertheless, it's easy to understand.

Edit:- Crap, my flowcharts messed up. Any genius out here can help me with it?

Thanks again :)

\­( ... \­)

Ah, the most important flowchart is understandable, the largest one, you should have no problem comprehending this solution.

Shashank Sistla - 7 years ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...