How to arrange a bunch of words so that the number of letters is minimized?

I'll start with an example to find out which algorithm I'm looking for:

For example, there are words one, twoand three. They can be arranged as follows:

three
w
one

or

  t
  h
t r
w e
one

Other examples:

   t
eight
 t r
 w e
 one

eightwo
    h
    r
  one
    e

 n
eightwo
 n  h
 e  r
  one
    e

eightwo
    h
    r
  one
 nine

and etc.

How can I achieve this algorithm to get

a) the number of smallest characters?
b) tight organization?
c) for any combination?

This is not a homework or interview question; I am trying to rebuild QlockTwo with a slightly different design.

+4
source share

All Articles