Last active
August 29, 2015 13:59
-
-
Save tom-galvin/10914746 to your computer and use it in GitHub Desktop.
DailyProgrammer Challenge #158i Solution (The ASCII Architect, pt. 1)
This file contains hidden or 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
# reddit.com/r/DailyProgrammer | |
# Solution to Challenge #158 (Intermediate): The ASCII Architect, pt. 1 | |
# I herd u liek spaghetti | |
input, output, longest = gets.chomp.split(''), [], 0 | |
while input.any? | |
output.unshift input[0] =~ /\d/ ? | |
(' ' * input.shift.to_i + '++__***---'[0, input.shift.ord - 'a'.ord + 1]) : | |
'++__***--- '[0, input.shift.ord - 'a'.ord + 1] | |
longest = output[0].length if output[0].length > longest | |
end | |
output.map{|s| s.reverse.rjust(longest, ' ').split('')}.reverse.transpose.map{|s| s.join}.each {|s| puts s} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment