Back
Close

Young diagrams and conjugates

Statement

 Goal

Give the conjugate of the partition p.

A partition of a positive integer n is a way of expressing n as a sum of positive integers. For example 3, 2 + 1 and 1 + 1 + 1 are all (disregarding the order of the summands) the partitions of the integer 3.
Given a partition of n, we can build its Young diagram as follows: take, for example, the partition 5 + 4 + 1 of 10, we draw (from higher summand to lower), an amount of stars equal to the summand:

5 -> *****
4 -> ****
1 -> *

By counting the stars horizontally we read again our original partition, but we quickly realize that by counting vertically we have found another partition of our original number 10, that is:

32221
|||||
*****
****
*

We say that 3 + 2 + 2 + 2 + 1 is the conjugate of the partition 5 + 4 + 1.

Give the conjugate of the partition p.
Input
A string representing a partition p.
Output
A string representing the conjugate partition of the partition p.
Constraints
The summands of p are given in non-increasing order.
0 < n < 100
Example
Input
5 + 4 + 1
Output
3 + 2 + 2 + 2 + 1

Game modes
Fastest, Shortest

Test cases
Test 1 Test
Input
5 + 4 + 1
Output
3 + 2 + 2 + 2 + 1

Validator 1 Validator
Input
7 + 1
Output
2 + 1 + 1 + 1 + 1 + 1 + 1

Symmetrical Test
Input
5 + 5 + 5 + 5 + 5
Output
5 + 5 + 5 + 5 + 5

Validator 2 Validator
Input
4 + 4 + 4 + 4
Output
4 + 4 + 4 + 4

Longer Test
Input
8 + 8 + 5 + 4 + 4 + 1 + 1
Output
7 + 5 + 5 + 5 + 3 + 2 + 2 + 2

Validator 3 Validator
Input
9 + 8 + 8 + 5 + 5 + 4 + 4 + 3 + 1 + 1
Output
10 + 8 + 8 + 7 + 5 + 3 + 3 + 3 + 1

Edge case Test
Input
1
Output
1

Validator 4 Validator
Input
1
Output
1

Edge case 2 Test
Input
1 + 1 + 1 + 1
Output
4

Validator 5 Validator
Input
1 + 1 + 1 + 1 + 1 + 1
Output
6

Edge case 3 Test
Input
9
Output
1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1

Validator 6 Validator
Input
3
Output
1 + 1 + 1

Even longer Test
Input
13 + 11 + 8 + 8 + 5 + 5 + 5 + 5 + 5 + 5 + 5 + 5 + 5 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1
Output
23 + 13 + 13 + 13 + 13 + 4 + 4 + 4 + 2 + 2 + 2 + 1 + 1

Validator 7 Validator
Input
19 + 13 + 10 + 10 + 1 + 1 + 1 + 1 + 1
Output
9 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 2 + 2 + 2 + 1 + 1 + 1 + 1 + 1 + 1

Even longer bis Test
Input
40 + 40 + 4 + 4 + 4 + 4
Output
6 + 6 + 6 + 6 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2

Validator 8 Validator
Input
4 + 4 + 4 + 4 + 4 + 4 + 4 + 3 + 3 + 2 + 2 + 1 + 1
Output
13 + 11 + 9 + 7

Solution language

Solution

Stub generator input