From: Matthew Moss Date: 2008-09-20T23:55:53+09:00 Subject: Re: One-Liners Mashup (#177 again) > Challenge: >   Print out a Serpinski carpet. Here ya go. Non-negative parameter to the function is recursion depth, so should be 0 for the "null 1x1 carpet", 1 for the 3x3, 2 for the 9x9, etc. This is golfed, and probably a bit more than 80 chars (gonna wrap in email, I bet). def carpet(n) def k(s,x,y) (s<=3||k(s/3,x/3,y/3))&&!(x%3==1&&y%3==1) end;s=3**n;s.times{|y|s.times{|x| print k(s,x,y)?"#":" "};puts} end Followup: Make my solution shorter. (There's got to be something nicer than using `times` twice and `print` once.