You are given a bunch of ASCII test-tubes, your task is to reduce number of test-tubes used.
Each test tube looks like this:
| |
| |
| |
|~~|
| |
| |
| |
| |
|__|
Obviously, ~~
is the water level. Test-tube can be also empty, in which case there are no ~~
characters inside. Single tube can contain up to 8 water level units.
You are given finite number of test tubes with different water levels inside. You have to pour the water in least amount of test-tubes possible, and output the result.
| | | | | | | | |~~| | |
| | | | | | | | | | | |
| | |~~| | | | | | | | |
|~~| | | | | | | | | |~~|
| | | | | | | | ------> | | | |
| | | | | | | | | | | |
| | | | |~~| | | | | | |
| | | | | | | | | | | |
|__| |__| |__| |__| |__| |__|
05 + 06 + 02 + 00 ------> 08 + 05
As you can see, test-tubes are separated with single space. Empty tubes should not be shown in output. This is code golf, so code with least number of bytes wins.
Test cases: http://pastebin.com/BC0C0uii
Happy golfing!