## ECOO '12 R3 P1 - The Word Garden

View as PDF

Points: 5 (partial)
Time limit: 2.0s
Memory limit: 64M

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

In addition to creating problems for the ECOO competition, I have an unusual landscaping business on the side. I create custom-made "Word Gardens". To make a Word Garden, I take one of my customers' favorite quotations, turn each word in the quotation into a tree, and then plant the trees in rows, packing them as tightly together as I can.

Here's an example, using a paraphrased quote from Hubert Dreyfus' classic book, What Computers Can't Do. The original quote was, "Since the Greeks invented logic and geometry the idea that all reasoning might be reduced to some kind of calculation has fascinated most of the West's rigorous thinkers".



i
ini
invni
invevni
G      invenevni
GrG    inventnevni
S      GrerG  inventetnevni  l
SiS    GreeerGinventedetnevnilol
SiniS  GreekeerG      i      logol
SincniSGreekskeerG     n     logigol
SincecniSt   G          v    logicigol
S   tht  r          e        l
i  theht e          n        o
n    t   e          t        g
c    h   k          e        i
e    e   s          d        c
========================================


r
rer
g                    reaer
geg                  reasaer
geoeg                reasosaer
geomoeg              reasonosaer
geomemoeg            reasoninosaer
geometemoeg          reasonininosaer
geometrtemoeg        reasoningninosaer
geometryrtemoeg               r
g       i      t       e
e      idi    tht      a
a    o  t  idedi  thaht  a  s
ana   m thtideaedithatahtala o
andna  etheht  i      t  alllan
a    t  t    d      h    a  i
n    r  h    e      a    l  n
d    y  e    a      t    l  g
========================================


r
rer
reder
reduder
m    reducuder
mim  reducecuder
migimreducedecuders      k
mighgim     r     sos    kik
mighthgim    e    somos  kinik
m        d   somemoskindnik
i b      u t    s      k o
gbeb     ctot   o      iofo
h b      e t    m      n o
t e      d o    e      d f
========================================
          c
cac
calac                f
calclac              faf
calcuclac            fasaf
calculuclac          fascsaf
calculaluclac        fascicsaf
calculataluclac      fascinicsaf
calculatitaluclac    fascinanicsaf
calculatioitaluclac  fascinatanicsaf
calculationoitaluclacfascinatetanicsaf
c         fascinatedetanicsaf
a                  f
l                  a
c                  s   m
u                  c  mom
l  h               i mosom
a hah              nmostsom
thasah             a   m o
i  h               t   oofo
o  a               e   s o
n  s               d   t f
========================================


r              t
rir            tht
rigir          thiht
rigogir        thiniht
W      rigorogir      thinkniht
WeW    rigororogir    thinkekniht
WeseW  rigorouorogir  thinkerekniht
WestseWrigorousuorogirthinkersrekniht
West'tseW      r              t
West's'tseW     i              h
t  W          g              i
tht e          o              n
thehts          r              k
t  t          o              e
h  '          u              r
e  s          s              s
========================================
    S
SiS
SiniS
SincniS
SincecniS
S
i
n
c
e
=========

Notice that each word tree has a "trunk" consisting of the original word repeated twice vertically, and then "leaves" added to the top half of the trunk so that each level of leaves corresponds to an increasing portion of the word, repeated forwards and backwards and centered on the trunk. The tree for the word Since is shown at right.

The word trees are always planted in rows with an exact width of characters. I plant the trees from left to right, placing each one as far to the left as I can without overlapping any previously planted tree. The ground consists of = characters, and the maximum height of any tree is characters (not including the ground).

The input will contain lines of text. Each line of text will contain a list of words with each pair of words separated by a single space character. Each word will consist of a sequence of alphanumeric characters (and possibly also punctuation characters in some cases).

Each line of text should be turned into a line of trees, as described above. The ground should always have exactly = characters. Each line of trees will always fit into a space of rows by columns.

#### Sample Input

Since the Greeks invented logic
and geometry the idea that all reasoning
might be reduced to some kind of
calculation has fascinated most of
the West's rigorous thinkers

#### Sample Output

See above. Note that each new row of trees should appear in the output window below the row before, not beside it as shown here. The rows are only shown side by side to save space.

Educational Computing Organization of Ontario - statements, test data and other materials can be found at ecoocs.org