Skip to content

Instantly share code, notes, and snippets.

@mrThe
Last active November 10, 2016 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrThe/9e734fe3e4c37c41739ae65b28418c7d to your computer and use it in GitHub Desktop.
Save mrThe/9e734fe3e4c37c41739ae65b28418c7d to your computer and use it in GitHub Desktop.
Text block generator
def block(str)
chars = str.upcase.chars
size = chars.size
result = Array.new(size) { Array.new(size) { ' ' } }
chars.each_with_index do |char, i|
result[0][i] = char
result[i][i] = char
result[i][0] = char
end
result.map do |res|
res.join(' ')
end.join("\n")
end
res = block(ARGV[0])
puts "`#{res}`"
# $ ruby block.rb hello
# `H E L L O
# E E
# L L
# L L
# O O`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment