Sums at the Workshop
A mathematics workshop in Ponce uses cards with sums whose terms are only 1, 2 and 3. You receive one such expression. Rearrange its terms in nondecreasing order and print the new expression. Keep every occurrence of every number; do not evaluate the sum.
Input
One line with a valid expression, without spaces, consisting of digits 1, 2 and 3 separated by + signs.
Output
Print the rearranged expression, without spaces or leading or trailing + signs.
Constraints
The expression has between 1 and 100 characters. A valid expression has odd length.
Example
| Input Example | Output Example |
|---|---|
| 3+1+2+1 | 1+1+2+3 |
All four terms are preserved.
Source
Adapted for OiPR 2026. Codeforces 339A — Helpful Maths.
Comments