Skip to content

Instantly share code, notes, and snippets.

@tom-galvin
Last active August 29, 2015 13:59
Show Gist options
  • Save tom-galvin/10914746 to your computer and use it in GitHub Desktop.
Save tom-galvin/10914746 to your computer and use it in GitHub Desktop.
DailyProgrammer Challenge #158i Solution (The ASCII Architect, pt. 1)
# 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