I have a bunch of boards I need to stack in as small a space as possible. Unfortunately, the boards fall over if I stack them more than 10 high. I need a program to tell me how to stack the boards to take as little horizontal space as possible, without stacking boards more than ten high, or having boards hanging out over empty space.
Write a program or function, that when given an array containing the lengths of boards, outputs as ASCII art the way to stack the boards to conserve as much horizontal space as possible, without stacking the boards more than 10 high or having any part of any board hanging out over empty space. Your ASCII art should show the configuration of the boards, with each one shown using a different character. There will be a maximum of 20 boards. For example, if the input was [2,2,4,2,2,4,4,4], a possible output is:
dhh dgg dff dee abc abc abc abc
which is a stable configuration (although this would fall over in ~0.1 seconds in real life).
An array containing up to 20 integers, showing the lengths of the boards.
ASCII art showing the configurations of the boards, as outlined above.
Note that there may be other solutions for the test cases, and the characters shown for each board may be different.
[12,2,2,2,3,4,4,8,8] -> ffgghhiii ddddeeeeeeee bbbbbbbbcccc aaaaaaaaaaaa [4,4,4,4,4,4,4,4,4,4,4,4] -> llll aaaa cfghk cfghk cfghk cfghk debij debij debij debij
This is code-golf, lowest score in bytes wins