Problem Statement
Ramanujan loved partitions. And he also loved natural numbers. So, yay! He has a problem for you.
The set S consists of the first 8*N natural numbers: S = { 1, 2, 3, ..., 8*N }. You have to find a subset W of S with the following properties:
- W contains exactly 2*N numbers.
- The sum of W is 4*N*N.
If there is a subset W satisfying the mentioned condition, find any one such subset. Return a string of size 8*N, where the ith character (1-indexed) is '1' if i belongs to W, and '0' otherwise. Any valid solution will be accepted.
Return an empty string if it is impossible to construct a valid subset for the given N.
Definition
- Class:
- EasyPartition
- Method:
- getPartition
- Parameters:
- int
- Returns:
- String
- Method signature:
- String getPartition(int N)
- (be sure your method is public)
Notes
- W is a subset of S, hence all elements of W must be distinct.
Constraints
- N will be between 1 and 50, inclusive.
Examples
1
Returns: "10100000"
W = {1,3} satisfies our conditions.
2
Returns: "0110110000000000"
4 * N * N = 16. W={2,3,5,7} Other possible solutions are {1,3,5,7}, {1,2,6,7}, {1,2,5,8} etc.
3
Returns: "010110110100000000000000"
W = {2,4,5,7,8,10} satisfies.
4
Returns: "01010110110101000000000000000000"
5
Returns: "0101010110110101010000000000000000000000"
6
Returns: "010101010110110101010100000000000000000000000000"
7
Returns: "01010101010110110101010101000000000000000000000000000000"
8
Returns: "0101010101010110110101010101010000000000000000000000000000000000"
9
Returns: "010101010101010110110101010101010100000000000000000000000000000000000000"
10
Returns: "01010101010101010110110101010101010101000000000000000000000000000000000000000000"
11
Returns: "0101010101010101010110110101010101010101010000000000000000000000000000000000000000000000"
12
Returns: "010101010101010101010110110101010101010101010100000000000000000000000000000000000000000000000000"
13
Returns: "01010101010101010101010110110101010101010101010101000000000000000000000000000000000000000000000000000000"
14
Returns: "0101010101010101010101010110110101010101010101010101010000000000000000000000000000000000000000000000000000000000"
15
Returns: "010101010101010101010101010110110101010101010101010101010100000000000000000000000000000000000000000000000000000000000000"
16
Returns: "01010101010101010101010101010110110101010101010101010101010101000000000000000000000000000000000000000000000000000000000000000000"
17
Returns: "0101010101010101010101010101010110110101010101010101010101010101010000000000000000000000000000000000000000000000000000000000000000000000"
18
Returns: "010101010101010101010101010101010110110101010101010101010101010101010100000000000000000000000000000000000000000000000000000000000000000000000000"
19
Returns: "01010101010101010101010101010101010110110101010101010101010101010101010101000000000000000000000000000000000000000000000000000000000000000000000000000000"
20
Returns: "0101010101010101010101010101010101010110110101010101010101010101010101010101010000000000000000000000000000000000000000000000000000000000000000000000000000000000"
21
Returns: "010101010101010101010101010101010101010110110101010101010101010101010101010101010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
22
Returns: "01010101010101010101010101010101010101010110110101010101010101010101010101010101010101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
23
Returns: "0101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
24
Returns: "010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
25
Returns: "01010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
26
Returns: "0101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
27
Returns: "010101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
28
Returns: "01010101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
29
Returns: "0101010101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010101010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
30
Returns: "010101010101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010101010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
31
Returns: "01010101010101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010101010101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
32
Returns: "0101010101010101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010101010101010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
33
Returns: "010101010101010101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010101010101010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
34
Returns: "01010101010101010101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010101010101010101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
35
Returns: "0101010101010101010101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010101010101010101010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
36
Returns: "010101010101010101010101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010101010101010101010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
37
Returns: "01010101010101010101010101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010101010101010101010101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
38
Returns: "0101010101010101010101010101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010101010101010101010101010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
39
Returns: "010101010101010101010101010101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010101010101010101010101010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
40
Returns: "01010101010101010101010101010101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010101010101010101010101010101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
41
Returns: "0101010101010101010101010101010101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010101010101010101010101010101010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
42
Returns: "010101010101010101010101010101010101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010101010101010101010101010101010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
43
Returns: "01010101010101010101010101010101010101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010101010101010101010101010101010101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
44
Returns: "0101010101010101010101010101010101010101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010101010101010101010101010101010101010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
45
Returns: "010101010101010101010101010101010101010101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010101010101010101010101010101010101010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
46
Returns: "01010101010101010101010101010101010101010101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010101010101010101010101010101010101010101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
47
Returns: "0101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
48
Returns: "010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
49
Returns: "01010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
50
Returns: "0101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010110110101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"