Python script to write a word using the word
That’s the best title I can come up with. The idea is to do this:
THISTHISTHISTHISTHISTHISTHISTHISTHISTHISTHISTHISTHISTHISTHISTHISTHIS
THISTHISTHISTHISTHISTHISTHISTHISTHISTHISTHISTHISTHISTHISTHISTHISTHIS
THIS THIS THIS THIS THIS THIS
THIS THIS THIS THIS THIS THIS
THISTHIS THISTHIS THIS THISTHIS THISTHIS THISTHISTHIS
THISTHIS THISTHIS THIS THISTHIS THISTHIS THISTHISTHIS
THISTHIS THISTHIS THISTHIS THISTHIS THIS
THISTHIS THISTHIS THISTHIS THISTHIS THIS
THISTHIS THISTHIS THIS THISTHIS THISTHIS THIS
THISTHIS THISTHIS THIS THISTHIS THISTHISTHISTHIS THIS
THISTHIS THISTHIS THIS THISTHIS THISTHISTHISTHIS THIS
THISTHIS THISTHIS THIS THIS THIS THIS
THISTHIS THISTHIS THIS THIS THIS THIS
THISTHISTHISTHISTHISTHISTHISTHISTHISTHISTHISTHISTHISTHISTHISTHISTHIS
THISTHISTHISTHISTHISTHISTHISTHISTHISTHISTHISTHISTHISTHISTHISTHISTHIS
With any number of alphanumeric characters. The idea comes from a reddit user posting something similar, and then my mind wandered.
Well, in a couple of hours the following python script was all I could come up with:
word = input("Give me a word: ")
# 2 line padding top,bottom
# 1 'word' padding left and right of entire word
# letters 3 words wide, 11 lines tall
result = ""
charlist = {
" ": "000000000000000000000000000000000",
"A": "010101101111111101101101101101101",
"B": "111101101101101111101101101101111",
"C": "111100100100100100100100100100111",
"D": "110111101101101101101101101111110",
"H": "101101101101111111101101101101101",
"I": "111111010010010010010010010111111",
"S": "111111100100111111111001001111111",
"T": "111111010010010010010010010010010"}
def letter(word, index, row, col):
l = charlist[word[index]]
i = ((row - 1) * 3 + (col - 1))
ret = l[i]
if (ret == "1"):
return " " * len(word)
else:
return word
#return str(index) * len(word)
for y in range(1,16):
result += " " + word
for i, c in enumerate(word):
for x in range(1,4):
if (y < 3 or y > 13):
result += word
else:
result += letter(word, i, y - 2, x)
if (i < len(word) - 1):
result += word
result += word + "\n"
print(result)
And it’s good enough for this exercise. I didn’t even finish encoding the full alphabet. A non-trivial exercise for the motivated might be to incorporate spaces correctly (ie - don’t use spaces in each individual ‘block’ but use it in the final word). An even more difficult task would be to procedurally generate each character.