Forum: Ruby Codegolf: Pascal's Triangle

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
94cc3e46cfc5bc361e409e2e884ecfa4?d=identicon&s=25 Drew Olson (dfg59)
on 2007-01-25 15:48
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))}*' ')
}
703fbc991fd63e0e1db54dca9ea31b53?d=identicon&s=25 Robert Dober (Guest)
on 2007-01-25 18:35
(Received via mailing list)
On 1/25/07, Drew Olson <olsonas@gmail.com> wrote:
>
>
>
There must be a solution with 42 characters, it's a well known law ;)
703fbc991fd63e0e1db54dca9ea31b53?d=identicon&s=25 Robert Dober (Guest)
on 2007-09-25 22:34
(Received via mailing list)
On 1/25/07, Erik Veenstra <erikveen@gmail.com> wrote:
>
Ok if I cannot have 42 I will accept 42+42, why not?

Robert
6b0967f63d03e99b6c07a3f5ed224c77?d=identicon&s=25 Erik Veenstra (Guest)
on 2007-09-25 22:37
(Received via mailing list)
This topic is locked and can not be replied to.