fork download
  1. def print_architect(input)
  2. disp_hash = {}
  3. ('a'..'j').to_a.each_with_index {|x,ix| disp_hash[x] = '++--***...'[0..ix].reverse } #make a hash of the strings for each letter
  4. string_ary = []
  5. max_len = 0 #stores the maximum length string, so we can add leading whitespace -- makes it simpler
  6. trailing_whitespaces = 0 #stores the number of spaces to add at the end, if we get a digit
  7. input.each_char do |x|
  8. str = disp_hash[x] #if it's a letter, get the string
  9. if str
  10. str = str + (' ' * trailing_whitespaces)
  11. string_ary.push str
  12. max_len = str.length if str.length > max_len
  13. trailing_whitespaces = 0
  14. else #it's a number
  15. trailing_whitespaces = x.to_i
  16. end
  17. end
  18. string_ary.map! {|str| (' ' * (max_len - str.length)) + str } #make all nodes uniform length, with leading whitespaces
  19. max_len.times do |ix|
  20. string_ary.each {|str| print str[ix]}
  21. puts
  22. end
  23. end
  24.  
  25. bridge = 'j3f3e3e3d3d3c3cee3c3c3d3d3e3e3f3fjij3f3f3e3e3d3d3c3cee3c3c3d3d3e3e3fj' #bridge
  26. mountains = 'abcdefghijihgfghihgfedcdefg' #mountains
  27. arrow = 'f1f2f3f4f5f6f5f4f3f2f1ff' #arrow
  28. frozen = 'f2cccdehj5jjhedcc2cf' #frozen castle
  29. [bridge, mountains, arrow, frozen].each do |input|
  30. print_architect input
  31. puts
  32. puts '--------------------'
  33. puts
  34. end
Success #stdin #stdout 0.02s 7464KB
stdin
Standard input is empty
stdout
.                 . .                 .
.*              **...**              *.
.***          ****...****          ***.
*-----      ------***------      -----*
*-------  --------***--------  -------*
*+++++++**++++++++***++++++++**+++++++*
-+++++++--++++++++---++++++++--+++++++-
-       --        ---        --       -
+       ++        +++        ++       +
+       ++        +++        ++       +

--------------------

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

--------------------

      *      
     ***     
    **-**    
   **---**   
  **--+--**  
 **--+++--** 
**--++ ++--**
*--++   ++--*
--++     ++--
-++       ++-
++         ++
+           +

--------------------

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

--------------------