# Codegolf: Pascal's Triangle

**URL:** <https://www.ruby-forum.com/t/codegolf-pascals-triangle/83362>\
**Category:** Ruby\
**Created:** [January 25, 2007, 3:48pm UTC](https://www.ruby-forum.com/t/codegolf-pascals-triangle/83362 "2007-01-25T15:48:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dfg59](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e0b2c6/32.png) [@dfg59](https://www.ruby-forum.com/u/dfg59)\
**Post date:** [January 25, 2007, 3:48pm UTC](https://www.ruby-forum.com/t/codegolf-pascals-triangle/83362/1 "2007-01-25T15:48:37Z")

</div>

Hi all!

I’ve been quite addicted to [www.codegolf.com](http://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](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))}_’ ')  
}

---

<div class="post-metadata">

**Author:** ![dfg59](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e0b2c6/32.png) [@dfg59](https://www.ruby-forum.com/u/dfg59)\
**Post date:** [January 25, 2007, 6:35pm UTC](https://www.ruby-forum.com/t/codegolf-pascals-triangle/83362/2 "2007-01-25T18:35:26Z")

</div>

On 1/25/07, Drew O. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 

There must be a solution with 42 characters, it’s a well known law 😉

---

<div class="post-metadata">

**Author:** ![dfg59](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e0b2c6/32.png) [@dfg59](https://www.ruby-forum.com/u/dfg59)\
**Post date:** [September 25, 2007, 10:34pm UTC](https://www.ruby-forum.com/t/codegolf-pascals-triangle/83362/3 "2007-09-25T22:34:41Z")

</div>

On 1/25/07, Erik V. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 

Ok if I cannot have 42 I will accept 42+42, why not?

Robert

---

<div class="post-metadata">

**Author:** ![dfg59](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e0b2c6/32.png) [@dfg59](https://www.ruby-forum.com/u/dfg59)\
**Post date:** [September 25, 2007, 10:37pm UTC](https://www.ruby-forum.com/t/codegolf-pascals-triangle/83362/4 "2007-09-25T22:37:16Z")

</div>

Not again… ;]

[Ruby Quiz - pp Pascal (#84)](http://www.rubyquiz.com/quiz84.html)  
[http://tinyurl.com/2dlua4](http://tinyurl.com/2dlua4)

gegroet,  
Erik V. - [http://www.erikveen.dds.nl/](http://www.erikveen.dds.nl/)
