aboutsummaryrefslogtreecommitdiff
path: root/challenge-268/2colours/php/ch-2.php
blob: 2526cd6f61a057e1c379fd306b2dd139d92fed30 (plain)
1
2
3
4
5
6
7
8
9
10
<?php

const PARENS = ['(', ')'];
const BRACKETS = ['[', ']'];
echo '@ints = ';
$ints = json_decode(str_replace(PARENS, BRACKETS, fgets(STDIN)));

sort($ints);

echo str_replace(BRACKETS, PARENS, json_encode(array_merge(...array_map(array_reverse(...), array_chunk($ints, 2)))));