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 6*N natural numbers. That is, S = {1, 2, ..., 6*N}. You have to partition S into three equally-large sets A, B, C. Additionally, this partition must be such that sum(C) = 2 * sum(A) = 2 * sum(B).
If there is no solution, return an empty String. Otherwise, return a String of length 6*N that describes any one valid solution. For each i, the i-th character (1-based index) of the return value should be 'a' if value i belongs to A, 'b' for B, or 'c' for C.
Definition
- Class:
- EpicPartition
- Method:
- createPartition
- Parameters:
- int
- Returns:
- String
- Method signature:
- String createPartition(int N)
- (be sure your method is public)
Constraints
- N will be between 1 and 100, inclusive.
Examples
1
Returns: ""
2
Returns: ""
4
Returns: "aaabababbbbabbcccccccaac"
A = {1,2,3,4,6,18,19,22}. Sum(A) = 75. B = {5,7,8,9,10,11,12,13}. Sum(B) = 75 C = {14,15,16,17,20,21,23,24}. Sum(C) = 150 Satisfies size(A) = 2 * 4, size(B) = 2 * 4, size(C) = 2 * 4. And union of A,B,C = {1,2,3,...6*4}. And sum(C) = 2 * sum(A) = 2 * sum(B)8
Returns: "abaaaaaabaabbaabbbbbbbbbbbbccccccccaaccccccacaac"