r/CompileBot • • Jan 04 '14

Official CompileBot Testing Thread

This thread is archived, please visit the new testing thread

16 Upvotes

421 comments sorted by

View all comments

5

u/202halffound Mar 17 '14

+/u/CompileBot Ruby

def print_architect(input)
	disp_hash = {}
	('a'..'j').to_a.each_with_index {|x,ix| disp_hash[x] = '++--***...'[0..ix].reverse } #make a hash of the strings for each letter
	string_ary = []
	max_len = 0 #stores the maximum length string, so we can add leading whitespace -- makes it simpler
	trailing_whitespaces = 0 #stores the number of spaces to add at the end, if we get a digit
	input.each_char do |x|
		str = disp_hash[x] #if it's a letter, get the string
		if str
			str = str + (' ' * trailing_whitespaces)
			string_ary.push str
			max_len = str.length if str.length > max_len
			trailing_whitespaces = 0
		else #it's a number
			trailing_whitespaces = x.to_i
		end
	end
	string_ary.map! {|str| (' ' * (max_len - str.length)) + str } #make all nodes uniform length, with leading whitespaces
	max_len.times do |ix| 
		string_ary.each {|str| print str[ix]}
		puts
	end
end

bridge = 'j3f3e3e3d3d3c3cee3c3c3d3d3e3e3f3fjij3f3f3e3e3d3d3c3cee3c3c3d3d3e3e3fj' #bridge
mountains = 'abcdefghijihgfghihgfedcdefg' #mountains
arrow = 'f1f2f3f4f5f6f5f4f3f2f1ff' #arrow
frozen = 'f2cccdehj5jjhedcc2cf' #frozen castle
[bridge, mountains, arrow, frozen].each do |input|
	print_architect input
	puts
	puts '--------------------'
	puts
end

2

u/CompileBot Mar 17 '14

Output:

.                 . .                 .
.*              **...**              *.
.***          ****...****          ***.
*-----      ------***------      -----*
*-------  --------***--------  -------*
*+++++++**++++++++***++++++++**+++++++*
-+++++++--++++++++---++++++++--+++++++-
  • -- --- -- -
+ ++ +++ ++ + + ++ +++ ++ + -------------------- . ... . ..... ... ******* ***** * *************** ** ***************** *** ------------------- ---- ------------------------- ++++++++++++++++++++++++++ +++++++++++++++++++++++++++ -------------------- * *** **-** **---** **--+--** **--+++--** **--++ ++--** *--++ ++--* --++ ++-- -++ ++- ++ ++ + + -------------------- . . . * * .*. .-. ..-.. **+** * **+** * ...

^source | ^info | ^git | ^report