Framed Reflection

100th Kata

You are given a message (text) that you choose to read in a mirror (weirdo). Return what you would see, complete with the mirror frame. Example:

'Hello World'

would give:

Words in your solution should be left-aligned.

Solutions

🐍 Python

def mirror(text):
    words=text.split()
    max_w_len = len(max(words))
    topbottom = "*"*(max_w_len+4)+'\n'
    res = topbottom + \
          ''.join([ '* ' + w[::-1] + ' '*(max_w_len-len(w)) + ' *\n' for w in words ]) + \
          topbottom[:-1]
    return res

Last updated