Say I have a pile of boxes:
I can create it in two steps:
BBB ↓ (empty) --- AAA ↓ BBB
But with this:
I need three steps:
A ↓ (empty pile) --- BB ↓ A --- A ↓ B BA
Given a pile of boxes, output the minimum number of steps needed to create that pile.
A step consists of dropping a row of boxes of the same type onto the current pile.
AAA can be dropped as a step, so can
A A, but
A B and
Input can be as a matrix, text, whatever. The input will always be a solid block - nothing like
Will ever be inputted, so you don't have to parse spaces / empty values.
This is code-golf, shortest wins!
AB BA => 3 A B C D E => 5 AAA AAA AAA => 3 ABCAB DEACB => 7 POTATOS DOBEYUM => 12