Codegolf: Pascal's Triangle

D

Drew Olson

Hi all!

I've been quite addicted to www.codegolf.com for a while and I'm trying
to skim down my Pascal's Triangle program. The challenge description is
here: http://codegolf.com/pascals-triangle. I'm currently at 84 bytes,
but some awesome ruby coders have done it in 43 bytes! Take a look at
the code and let me know if there's anything glaringly obvious I could
do the reduce character count. New lines have been added for
readability, there are no new lines in the true code.

def f(n)
n<1?1:n*f(n-1)
end;

34.times{|i|
puts((0..i).map{|j|f(i)/(f(j)*f(i-j))}*' ')
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top