In: Computer Science
In math class, a student has written down a sequence of 16 numbers on the blackboard. Below each number, a second student writes down how many times that number occurs in the sequence. This results in a second sequence of 16 numbers. Below each number of the second sequence, a third student writes down how many times that number occurs in the second sequence. This results in a third sequence of numbers. In the same way, a fourth, fifth, sixth, and seventh student each construct a sequence from the previous one. Afterward, it turns out that the first six sequences are all different. The seventh sequence, however, turns out to be equal to the sixth sequence. Give one sequence that could have been the sequence written down by the first student. Explain which solution strategy or algorithm you have used.
Looking at the problem the best way is to go from bottom to top. In this case from 7th sequence to 1st sequence.
Now from the last line we understand that 7th and 6th sequence are exactly same.
Assume 6th sequence is also all 9s, 7th becomes all 16.
6th: 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9
7th: 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16
Thinking around this line, it is only possible when the 6th sequence is all 16. Only then the 7th sequence will be all 16 as there are 16 16's in the previous sequence.
1: ?
2: ?
3: ?
4: ?
5: ?
6: 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16
7: 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16
Now moving to previous sequence i.e. 5th. Looking at the 6th sequence, it seems that all numbers in 5th sequence are same. It can be anything but as a sequence is not to be repeated in the first 4 ones, assuming 5th sequence is all n(n<>16)
So we have:
1: ?
2: ?
3: ?
4: ?
5: n n n n n n n n n n n n n n n n (n<>16)
6: 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16
7: 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16
Going for 4th sequence; we see 5th sequence consists all n. So now when there seems no option, we assume again. Assuming n = 9; it shows something like this:
5: 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9
6: 16 ...16... 16
Looks correct. But all n=9 is not possible. If n = 9 that means 4th sequence can only be of 9 elements or of 18 elements. But we have 16. Thinking around it again, we see n = 16 fits perfect again! But 5th sequence cannot be same as 6th sequence.
If we think logically, n can be anything that is a divisor of 16. So n can be 1,2,4,8.
trying to fit in 4, we fail at a previous step as below. 4th sequence goes wrong.
2 | 2 | 2 | 2 | 4 | 4 | 4 | 4 | 6 | 6 | 6 | 6 | 8 | 8 | 8 | 8 |
4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 |
16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 |
16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 |
But if we go for n =8, that might fit lets read along to find out.
Current sequence state:
1 | ? | |||||||||||||||
2 | ? | |||||||||||||||
3 | ? | |||||||||||||||
4 | ? | |||||||||||||||
5 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 |
6 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 |
7 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 |
16 |
So as stated earlier in case of 9, We see 2 8th are possible
Hence.
Sequences we have is
1 | ? | |||||||||||||||
2 | ? | |||||||||||||||
3 | ? | |||||||||||||||
4 | m | m | m | m | m | m | m | m | n | n | n | n | n | n | n | n |
5 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 |
6 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 |
7 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 |
Now, we follow similar process, m,n <=8 divisor of 8, but m <>n as then it would be all 16 in next sequence.
We keep n as 8 again and reduce n to 4
1 | ? | |||||||||||||||
2 | ? | |||||||||||||||
3 | m | m | m | m | n | n | n | n | o | o | o | o | o | o | o | o |
4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 |
5 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 |
6 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 |
7 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 |
So again, m,n,o<4 and divisor of 4. but m<>n or else any of the next sequence will be repeated.
o < 8 and divisor of 8.
Again applying same logic,
we have below as the second sequence:
1 | ? | |||||||||||||||
2 | a | a | b | b | c | c | c | c | d | d | d | d | d | d | d | d |
3 | 2 | 2 | 2 | 2 | 4 | 4 | 4 | 4 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 |
4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 |
5 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 |
6 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 |
7 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 |
now d in (1,2,4,8) c in (1,2,4) ;b in (1,2); a in (1)
if a = 1, b cannot be 1 hence b is 2. So c cannot be in 1,2 so c = 4 and hence d cannot be 1,2,4 hence d = 8
Final sequence is :
1 | ? | |||||||||||||||
2 | 1 | 1 | 2 | 2 | 4 | 4 | 4 | 4 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 |
3 | 2 | 2 | 2 | 2 | 4 | 4 | 4 | 4 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 |
4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 |
5 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 |
6 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 |
7 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 | 16 |
So Sequence 1 can include any numbers irrespective of any clause which has
first 2 numbers different.
next 2 numbers same.
next 4 numbers same.
next 8 numbers same.
So sample sequence is
a,b,c,c,d,d,d,d,e,e,e,e,e,e,e,e.
only condition being a<>b<>c<>d<>e
Hope this helped!
Thank you! Best of Luck!