रूबी 2.3.1, 777 752 बाइट्स
Edit_0: मैं पूरी तरह से कुछ गोल्फ चर उपयोग और कुछ अन्य सामानों को याद कर रहा हूं।
@o=Array.new;$*.each_with_index do|j,i|a,e,n,b,u,q,r,z,y=0,j[0].to_i,j[1].to_i,j[2].to_i,j[3].to_i,['°','¯','-','^',"'"],['v','w','o','_',"-"],Array.new(7," ")," ";g,h=[z,["(#{q[e]}#{r[n]}#{q[e]})"," _|_ ","/[|]\\"," | "," / \\ "],[" "," , ","(#{q[e]}#{r[n]}#{q[e]})"]],[z,[" "," ^\"^ "],[" () ", " ´` "],[" .|. "," :\": "]];2.times{h[3].unshift(" | ")}unless b==1;if b<1 && u<1;@o.push(z);elsif b<1;u<3 ? (a=5):(a=3);a.times{h[u].push(y)};@o.push(h[u]);elsif u<1;b==1 ? (a=2):(a=4);a.times{g[b].unshift(y)};@o.push(g[b]);elsif u>0;2.times{h[u].push(y)}if u<3&&b>1;@o.push(h[u]+g[b]);end;@o.push(z);end;@o.transpose.each do|v|;v.each do |w|;print w;end;print"\n";end
सजावट के चर के एन संख्या में ले जाता है। निश्चित रूप से कुछ और गोल्फिंग हैं जो इसके साथ किए जा सकते हैं। मैं रूबी की बहुत सारी चाल से परिचित नहीं हूँ, लेकिन यहाँ एक शॉट है! मैं इसे हल करने में सक्षम होने पर भी खुश हूं।
संयुक्त राष्ट्र के golfed
@output = Array.new
$*.each_with_index do |j, i|
# output decoration combo
s = 0
# set up vars for decoration input
e = j[0].to_i
n = j[1].to_i
b = j[2].to_i
u = j[3].to_i
# Setup decorations/misc
eyes = ['°','¯','-','^',"'"]
nose = ['v','w','o','_',"-"]
nothing = Array.new(7, " ")
skeleton = ["(#{eyes[e]}#{nose[n]}#{eyes[e]})", " _|_ ", "/[|]\\", " | ", " / \\ "]
pumpkin = [" ", " , ", "(#{eyes[e]}#{nose[n]}#{eyes[e]})"]
fbat = [" ", " ^\"^ "]
rbat = [" () ", " ´` "]
spider = [" | ", " .|. ", " :\": "]
spider.unshift(" | ") unless b == 1
a = " "
bot = [nothing, skeleton, pumpkin]
top = [nothing, fbat, rbat, spider]
# if bottom and upper are empty
if b < 1 && u < 1
@output.push(nothing)
# if bottom is empty
elsif b < 1
u < 2 ? (s = 3) : (s = 5)
s.times {top[u].push(a)}
@output.push(top[u])
# if upper is empty
elsif u < 1
# put in white space before the decorations
b == 1 ? (s = 2) : (s = 5)
s.times {bot[b].unshift(a)}
@output.push(bot[b])
# if there's an upper decoration
elsif u > 0
# put in the top deco
2.times {top[u].push(a)} if u < 3 && b > 1
@output.push(top[u] + bot[b])
end
# Input the empty column
@output.push(nothing)
end
# Transpose the array of arrays so that
# instead of outputting each line of a single each decoration
# what's output is each line of each decoration.
# Example:
# [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5]]
# [[1, 1, 1, 1, 1], [2, 2, 2, 2, 2], [3, 3, 3, 3, 3], [4, 4, 4, 4, 4], [5, 5, 5, 5, 5]]
@output.transpose.each do |data|
data.each do |data1|
print data1
end
print "\n"
end
निम्नलिखित:
ruby deco_g.rb 0000 0001 0002 0003 1110 1111 1112 1113 2220 2221 2222 2223 3310 3312 3321 3323
इसे आउटपुट करता है:
() | () .|. () | () |
^"^ ´` | ^"^ ´` :": ^"^ ´` | ´` ^"^ |
.|. (¯w¯) (¯w¯) (¯w¯) (¯w¯) .|. (^_^) (^_^) .|.
:": _|_ _|_ _|_ _|_ :": _|_ _|_ :":
/[|]\ /[|]\ /[|]\ /[|]\ /[|]\ /[|]\
| | | | , , , , | | , ,
/ \ / \ / \ / \ (-o-) (-o-) (-o-) (-o-) / \ / \ (^_^) (^_^)
9999?