In [208]:
from itertools import repeat, product
import re
vowels=['e','i','o']
consonants=['d','h','l']
seed1 = "ohellohi"
seed2 = "iliehide"
line = lambda phr, nchr=40: "".join(repeat(phr, int(nchr/len(phr))))
page = lambda line, nlines=22: "\n".join(repeat(line, nlines))
chars_of = lambda text: list(map(list, text.split('\n')))
text_of = lambda chars: "\n".join(map(lambda l: "".join(l), chars))
trios = {}
for i in range(3):
    for j in range(3):
        trios[(vowels[i], vowels[j])] = vowels[-(i+j) % 3]
        trios[(consonants[i], consonants[j])] = consonants[-(i+j) % 3]
        trios[(vowels[i], consonants[j])] = vowels[-(i+j) % 3]
        trios[(consonants[i], vowels[j])] = consonants[-(i+j) % 3]
        
def invert_char(char):
    if char in vowels:
        return consonants[(vowels.index(char)+1) % 3]
    else:
        return vowels[(consonants.index(char)+1) % 3]
def flip_chars(text, char1, char2, vacant='X'):
    text = text.replace(char1,'X')
    text = text.replace(char2,char1)
    return text.replace('X',char2)
def transpose(text, width=20, nlines=22):
    return text_of(list(map(list, zip(*chars_of(text*2)[1:41])))[10:nlines+10])
def sum(text1, text2, numchars=40, numlines=22):
    chars1 = chars_of(text1)
    chars2 = chars_of(text2)
    for i in range(numlines):
        for j in range(numchars):
            chars1[i][j] = trios[chars1[i][j], chars2[i][j]]
    return text_of(chars1)
def grow_with_inversion(seed1, seed2, char1, char2):
    base = page(line(seed1, nchr=24) + line(seed2, nchr=16), 11)
    return base + "\n" + flip_chars(base,'i','o')
def g_o_l(text, width=40, height=22): #Conway's Game of Life
    old = chars_of(text)
    def v(row, col):
        score = 0
        for i in range(max(0,row-1), min(height, row+2)):
            for j in range(max(0,col-1), min(width, col+2)):
                if (i,j) != (row,col) and old[i][j] in consonants:
                    score += 1
        return score
    def new_val(i,j):
        if old[i][j] in consonants and (v(i,j)>3 or v(i,j)<2):
            return invert_char(old[i][j])
        elif old[i][j] in vowels and v(i,j) == 3:
            return invert_char(old[i][j])
        else:
            return old[i][j]
    return text_of(list(map(lambda i: list(map(
        lambda j: new_val(i,j), range(width))), range(height))))

one = grow_with_inversion(seed1, seed2, 'i', 'o')
two = transpose(one)
three = sum(one,two)
four = g_o_l(three)
five = g_o_l(g_o_l(g_o_l(g_o_l(g_o_l(g_o_l(g_o_l(g_o_l(four))))))))
six = re.sub(r"e|i|o"," ",five)

print("\n\n".join([one,two,three,four,five,six]))
ohellohiohellohiohellohiiliehideiliehide
ohellohiohellohiohellohiiliehideiliehide
ohellohiohellohiohellohiiliehideiliehide
ohellohiohellohiohellohiiliehideiliehide
ohellohiohellohiohellohiiliehideiliehide
ohellohiohellohiohellohiiliehideiliehide
ohellohiohellohiohellohiiliehideiliehide
ohellohiohellohiohellohiiliehideiliehide
ohellohiohellohiohellohiiliehideiliehide
ohellohiohellohiohellohiiliehideiliehide
ohellohiohellohiohellohiiliehideiliehide
ihellihoihellihoihellihooloehodeoloehode
ihellihoihellihoihellihooloehodeoloehode
ihellihoihellihoihellihooloehodeoloehode
ihellihoihellihoihellihooloehodeoloehode
ihellihoihellihoihellihooloehodeoloehode
ihellihoihellihoihellihooloehodeoloehode
ihellihoihellihoihellihooloehodeoloehode
ihellihoihellihoihellihooloehodeoloehode
ihellihoihellihoihellihooloehodeoloehode
ihellihoihellihoihellihooloehodeoloehode
ihellihoihellihoihellihooloehodeoloehode

eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
llllllllllllllllllllllllllllllllllllllll
llllllllllllllllllllllllllllllllllllllll
ooooooooooiiiiiiiiiiiooooooooooiiiiiiiii
hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
iiiiiiiiiioooooooooooiiiiiiiiiiooooooooo
ooooooooooiiiiiiiiiiiooooooooooiiiiiiiii
hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
llllllllllllllllllllllllllllllllllllllll
llllllllllllllllllllllllllllllllllllllll
ooooooooooiiiiiiiiiiiooooooooooiiiiiiiii
hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
iiiiiiiiiioooooooooooiiiiiiiiiiooooooooo
iiiiiiiiiioooooooooooiiiiiiiiiiooooooooo
llllllllllllllllllllllllllllllllllllllll
iiiiiiiiiioooooooooooiiiiiiiiiiooooooooo
eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
iiiiiiiiiioooooooooooiiiiiiiiiiooooooooo
dddddddddddddddddddddddddddddddddddddddd
eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee

ilehhiloilehhiloilehhiloohoelodeohoelode
odillodeodillodeodillodeeleidehieleidehi
odillodeodillodeodillodeeleidehieleidehi
odillodeododdehiehoddodeeleidehoidiohilo
ehoddehiehoddehiehoddehiidiohiloidiohilo
ehoddehiehillodeodillehiidiohilieleidehi
odillodeododdehiehoddodeeleidehoidiohilo
ehoddehiehoddehiehoddehiidiohiloidiohilo
ilehhiloilehhiloilehhiloohoelodeohoelode
odillodeodillodeodillodeeleidehieleidehi
odillodeodillodeodillodeeleidehieleidehi
edilledoedoddiheihoddedooloidohoedeohelo
ihoddiheihoddiheihoddiheedeoheloedeohelo
ihoddiheihilledoedilliheedeohelioloidohi
ihoddiheihilledoedilliheedeohelioloidohi
edilledoedilledoedilledooloidohioloidohi
ihoddiheihilledoedilliheedeohelioloidohi
olehholiolehholiolehholiihielideihielide
ihoddiheihoddiheihoddiheedeoheloedeohelo
ihoddiheihilledoedilliheedeohelioloidohi
olehholiolehholiolehholiihielideihielide
olehholiolehholiolehholiihielideihielide

ieehhieoieehhieoieehhieooooeeoieoooeeoie
ddieeodhddieeodhddieeodhhlhldehlhlhldehl
ddieeodhddieeodhddieeodhhlhldehlhlhldehl
ddieeodhddoiiehlhhoiiodhhlhldehdldldhild
hhoiiehlhhoiiehlhhoiiehlldldhildldldhild
hhoiiehlhhieeodhddieeehlldldhillhlhldehl
ddieeodhddoiiehlhhoiiodhhlhldehdldldhild
hhoiiehlhhoiiehlhhoiiehlldldhildldldhild
lleooildlleooildlleooilddhdhlodhdhdhlodh
ddieeodhddieeodhddieeodhhlhldehlhlhldehl
ddieeodhddieeodhddieeodhhlhldehlhlhldehl
hdieeeddhdoiiihhlhoiiedddldldohdhdhdheld
lhoiiihhlhoiiihhlhoiiihhhdhdheldhdhdheld
lhoiiihhlhieeeddhdieeihhhdhdhelldldldohl
lhoiiihhlhieeeddhdieeihhhdhdhelldldldohl
hdieeeddhdieeeddhdieeedddldldohldldldohl
lhoiiihhlhieeeddhdieeihhhdhdhelldldldohl
dleooolldleooolldleooolllhlhlidhlhlhlidh
lhoiiihhlhoiiihhlhoiiihhhdhdheldhdhdheld
lhoiiihhlhieeeddhdieeihhhdhdhelldldldohl
dleooolldleooolldleooolllhlhlidhlhlhlidh
oeehhoeioeehhoeioeehhoeiioieeiieioieeiie

ihhooeoieooooeoieooooeoiiiioeoioiiioeoie
idheeiiieieeeiiieieeeiiiiiioieooiiioieoe
iieooiioiieooiioiieooiidlolhieoehdheieoe
ieeooieoieieeoieoiieeieddodhieoidldioiei
iiieeoioiiieeoioiiieeoldhehioieieheioiei
ieieeieoieoooeoieooooohdoeoioieeoeoeieoe
eoooieoeooehhieieeeoeeiieooeieoieieioiei
ioeohleieehooleieehhoiooieoioieieieioiei
ieiehdioiileedioiilheoeeoieieoioioioeoio
hloilhdeoddllhdeoddlieiieolhleoeoeoeieoe
hloilhdeoddllhdeoddlieiieolhleoeoeoeieoe
lloilldoedhdddheihhdoiieoohhlooioioioeei
ddeoddheihhdddheihhdoooieelldeeioioioeei
ioeoddeeiediilooeodliooieeieoeeeieieiooe
ooeohdeeiediilooeoddiooieeiioeeeieieiooe
ioooiiooeooddiooeooioiieooieiooeieieiooe
oeieeoeioeoooioeiooooehlieiioeeeieieiooe
eooiiiooeooiiiooeooiiiddhihoeiioeleoeiio
eiieeeioeiieeeioeiieeeiddedloeeilllioeei
eoieeeooeoeoooiioieooeodlelloeeedddeiooe
ildooieoeeoooieoeeoooieooeoieiiioeoieiio
ohhooioeiooooioeiooooioeeieoeiioeieoeiie

 hh                                     
 dh                                     
                       dl lh    hdh     
                       dd dh    dld     
                      ldh h      h      
                      hd                
           hh                           
    hl    h  l    hh                    
    hd    l  d    lh                    
hl  lhd  ddllhd  ddl      lhl           
hl  lhd  ddllhd  ddl      lhl           
ll  lld  dhdddh  hhd      hhl           
dd  ddh  hhdddh  hhd      lld           
    dd    d  l    dl                    
    hd    d  l    dd                    
           dd                           
                      hl                
                      ddh h      l      
                       dd dl    lll     
                       dl ll    ddd     
 ld                                     
 hh