Skip to main content
added 74 characters in body
Source Link
ratchet freak
  • 1.4k
  • 1
  • 9
  • 11

D 134134 128 chars

import std.stdio;void main(){int n,m;int[]l=[0,1m;int[]l,0]k=[0,k;readf1];readf("%d",&n);foreach(i;0..n){writeln(ll=k~0);k=[];foreach(e;l)k~=m+(m=e);l=k~0;;}}

output for 9 is

>9
[0, 1, 0]
[0, 1, 1, 0]
[0, 1, 2, 1, 0]
[0, 1, 3, 3, 1, 0]
[0, 1, 4, 6, 4, 1, 0]
[0, 1, 5, 10, 10, 5, 1, 0]
[0, 1, 6, 15, 20, 15, 6, 1, 0]
[0, 1, 7, 21, 35, 35, 21, 7, 1, 0]
[0, 1, 8, 28, 56, 70, 56, 28, 8, 1, 0]

taking full advantage of "you may format it however you like"; there is a space between each number and a linebreak

edit repositioned the assignment to l to shave of some chars

D 134 chars

import std.stdio;void main(){int n,m;int[]l=[0,1,0],k;readf("%d",&n);foreach(i;0..n){writeln(l);k=[];foreach(e;l)k~=m+(m=e);l=k~0;}}

output for 9 is

>9
[0, 1, 0]
[0, 1, 1, 0]
[0, 1, 2, 1, 0]
[0, 1, 3, 3, 1, 0]
[0, 1, 4, 6, 4, 1, 0]
[0, 1, 5, 10, 10, 5, 1, 0]
[0, 1, 6, 15, 20, 15, 6, 1, 0]
[0, 1, 7, 21, 35, 35, 21, 7, 1, 0]
[0, 1, 8, 28, 56, 70, 56, 28, 8, 1, 0]

taking full advantage of "you may format it however you like"; there is a space between each number and a linebreak

D 134 128 chars

import std.stdio;void main(){int n,m;int[]l,k=[0,1];readf("%d",&n);foreach(i;0..n){writeln(l=k~0);k=[];foreach(e;l)k~=m+(m=e);}}

output for 9 is

>9
[0, 1, 0]
[0, 1, 1, 0]
[0, 1, 2, 1, 0]
[0, 1, 3, 3, 1, 0]
[0, 1, 4, 6, 4, 1, 0]
[0, 1, 5, 10, 10, 5, 1, 0]
[0, 1, 6, 15, 20, 15, 6, 1, 0]
[0, 1, 7, 21, 35, 35, 21, 7, 1, 0]
[0, 1, 8, 28, 56, 70, 56, 28, 8, 1, 0]

taking full advantage of "you may format it however you like"; there is a space between each number and a linebreak

edit repositioned the assignment to l to shave of some chars

Source Link
ratchet freak
  • 1.4k
  • 1
  • 9
  • 11

D 134 chars

import std.stdio;void main(){int n,m;int[]l=[0,1,0],k;readf("%d",&n);foreach(i;0..n){writeln(l);k=[];foreach(e;l)k~=m+(m=e);l=k~0;}}

output for 9 is

>9
[0, 1, 0]
[0, 1, 1, 0]
[0, 1, 2, 1, 0]
[0, 1, 3, 3, 1, 0]
[0, 1, 4, 6, 4, 1, 0]
[0, 1, 5, 10, 10, 5, 1, 0]
[0, 1, 6, 15, 20, 15, 6, 1, 0]
[0, 1, 7, 21, 35, 35, 21, 7, 1, 0]
[0, 1, 8, 28, 56, 70, 56, 28, 8, 1, 0]

taking full advantage of "you may format it however you like"; there is a space between each number and a linebreak