Last active
November 10, 2016 11:39
-
-
Save mrThe/9e734fe3e4c37c41739ae65b28418c7d to your computer and use it in GitHub Desktop.
Text block generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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