Finding the kth number when groups of numbers are listed such that they add up to a specific sum A toy set contains blocks showing the numbers from 1 to 9. There are plenty of blocks
showing each number and blocks showing the same number are indistinguishable. We
want to examine the number of different ways of arranging the blocks in a sequence so
that the displayed numbers add up to a fixed sum.
For example, suppose the sum is 4. There are 8 different arrangements:
1 1 1 1
1 1 2
1 2 1
1 3
2 1 1
2 2
3 1
4
The rows are arranged in dictionary order (that is, as they would appear if they were
listed in dictionary).
In each of the cases below, you are given the desired sum S and a number K. You have
to write down the Kth line when all arrangements that add up to S are written down
as described above. For instance, if S is 4 and K is 5, the answer is 2 1 1. Remember
that S may be large, but the numbers on the blocks are only from 1 to 9.
S = 9, K = 156
How do I do this?
 A: Posted too soon. Figured out the answer.
We need to split up each number into smaller sections.
Fistly, if we list out the first few possibilities if n ranges from 1-4, we'll see that the total possibilities is 2^(n-1)
So if n=9, 2^8 is the total possibilities
Now the first few sums will start with 1 and is essentially 1+8, or 1+(different ways to split up 8).
Different ways to split up 8 = 2^7 ways = 128 ways
We need to find the 156th number, so 156-128 = 28. This means that there is 28 more ways to go. 
The next part is 2+7.
there's 2^6 ways to split 7, and 2^5 such that the the 7 starts with 1. As 2^5= 32 and 32>28, we know that the second number is 1. 
As 32-28 = 4, so it's safe to assume the answer would be towards the end of the list
the 32nd number would be 6
31st = 51
30th = 42
29th = 411
28th = 33
Therefore the numbers are 2 1 3 3
A: My solution is $$(2, 1, 3, 3)$$
I made a list of all $256$ possibilities, sorted them and took the $156$th
Edit
I made a mistake in sorting 
Now it should be right. The table is to show that I did it for real and did not copy the other answer :)
$
\begin{array}{l|l}
n & list \\
\hline
 1 & \{1,1,1,1,1,1,1,1,1\} \\
 2 & \{1,1,1,1,1,1,1,2\} \\
 3 & \{1,1,1,1,1,1,2,1\} \\
 4 & \{1,1,1,1,1,1,3\} \\
 5 & \{1,1,1,1,1,2,1,1\} \\
\ldots & \ldots\\
 152 & \{2,1,2,4\} \\
 153 & \{2,1,3,1,1,1\} \\
 154 & \{2,1,3,1,2\} \\
 155 & \{2,1,3,2,1\} \\
 156 & \{2,1,3,3\} \\
 157 & \{2,1,4,1,1\} \\
 158 & \{2,1,4,2\} \\
 159 & \{2,1,5,1\} \\
 160 & \{2,1,6\} \\
 161 & \{2,2,1,1,1,1,1\} \\
\ldots & \ldots\\
 253 & \{7,1,1\} \\
 254 & \{7,2\} \\
 255 & \{8,1\} \\
 256 & \{9\} \\
\end{array}
$
