Skip to content

Instantly share code, notes, and snippets.

@rubyworks
Created February 23, 2010 14:56
Show Gist options
  • Save rubyworks/312256 to your computer and use it in GitHub Desktop.
Save rubyworks/312256 to your computer and use it in GitHub Desktop.
Oneliner - Pascal's Triangle
a=[];10.times{|n|a<<1;puts" "*(9-n)*3+"%6d"*-~n%a;n.times{|i|a[n]+=a[n-=1]}}
a=[];10.times{|n|a<<1;puts" "*(9-n)*3+"%6d"*(n+1)%a;n.times{|i|a[n]+=a[n-=1]}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment