Pascal's Triangle

Given N; generate Pascal's triangle up to N rows.

Each column should have one space after it unless it is the last column.
All numbers should be right-aligned to the column.

IN

10

OUT

1
1 1
1 2  1
1 3  3  1
1 4  6  4   1
1 5 10 10   5   1
1 6 15 20  15   6  1
1 7 21 35  35  21  7  1
1 8 28 56  70  56 28  8 1
1 9 36 84 126 126 84 36 9 1

IN

1

OUT

1

IN

2

OUT

1
1 1

IN

3

OUT

1
1 1
1 2 1

IN

4

OUT

1
1 1
1 2 1
1 3 3 1

IN

5

OUT

1
1 1
1 2 1
1 3 3 1
1 4 6 4 1

IN

6

OUT

1
1 1
1 2  1
1 3  3  1
1 4  6  4 1
1 5 10 10 5 1

IN

7

OUT

1
1 1
1 2  1
1 3  3  1
1 4  6  4  1
1 5 10 10  5 1
1 6 15 20 15 6 1

IN

8

OUT

1
1 1
1 2  1
1 3  3  1
1 4  6  4  1
1 5 10 10  5  1
1 6 15 20 15  6 1
1 7 21 35 35 21 7 1

IN

9

OUT

1
1 1
1 2  1
1 3  3  1
1 4  6  4  1
1 5 10 10  5  1
1 6 15 20 15  6  1
1 7 21 35 35 21  7 1
1 8 28 56 70 56 28 8 1
Login to submit solution


29 symbols pyth
Fri Oct 21 14:35:10 2016 Sait2000
VJmm.cdkhdQjdm.[;l`@eJd`@NdlN
35 symbols pyth
Fri Oct 21 14:17:05 2016 Sait2000
VtJ.u+sMC,N+ZN1QYjdm.[;l`@eJd`@NdlN
38 symbols pyth
Fri Oct 21 14:09:12 2016 Sait2000
JYVQ aJ=+sMC,Y+ZY1)VJjdm.[;l`@Yd`@NdlN
39 symbols pyth
Mon Sep 19 16:01:37 2016 Sait2000
JYVQ aJ=Y+sMC,+ZYY1)VJjdm.[;l`@Yd`@NdlN
40 symbols pyth
Mon Sep 19 06:49:11 2016 Sait2000
JYVQ aJ=Y+sMC,+ZYY1)VJjdm.[\ l`@Yd`@NdlN
42 symbols pyth
Mon Sep 19 03:14:25 2016 Sait2000
JYVQ aJ=Y+sMC,+ZYY1)VJjdm.[\ l+k@Yd+k@NdlN
43 symbols pyth
Mon Sep 19 02:58:42 2016 Sait2000
JYVQ aJ=Y+sMC,+ZYY1)VJjdm.[" "l+k@Yd+k@NdlN
46 symbols pyth
Sun Sep 18 21:03:16 2016 Sait2000
J]]1VtQ aJsM.T,+ZeJeJ)VJjdm.[" "l+k@eJd+k@NdlN
48 symbols pyth
Sun Sep 18 21:00:54 2016 Sait2000
J]]1VStQ aJsM.t,+ZeJeJZ)VJjdm.[" "l+k@eJd+k@NdlN
51 symbols pyth
Sun Sep 18 20:50:16 2016 Sait2000
J]]1VtQK+ZeJ aJm+@Kd@KhdlK)VJjdm.[" "l+k@eJd+k@NdlN
54 symbols pyth
Sun Sep 18 20:40:20 2016 Sait2000
J]]1VStQK+Z+eJZ aJm+@Kd@KhdhN)VJjdm.[" "l+k@eJd+k@NdlN
56 symbols pyth
Sun Sep 18 20:35:23 2016 Sait2000
J]]1VStQK+Z+eJZ aJm+@Kd@KhdhN)VJjdm%%"%%%ss"l+k@eJd@NdlN
123 symbols python2
Fri Sep 16 06:30:21 2016 Sait2000
a=b=[]
for z in[zip]*input():b=map(sum,z(b,[0]+b))+[1];a+=b,
for c in a:print" ".join("%%%ss"%len(`p`)%q for p,q in z(b,c))
127 symbols python2
Fri Sep 16 06:19:01 2016 Sait2000
a=b=[]
for z in[zip]*input():b=[1]+map(sum,z(b,b[1:]+[0]));a+=b,
for c in a:print" ".join("%%%ss"%len(`p`)%q for p,q in z(b,c))
128 symbols python2
Fri Sep 16 06:10:35 2016 Sait2000
a=b=[]
for i in" "*input():b=[1]+map(sum,zip(b,b[1:]+[0]));a+=b,
for c in a:print i.join("%%%ss"%len(`p`)%q for p,q in zip(b,c))
129 symbols python2
Fri Sep 16 05:58:58 2016 Sait2000
a=b=[]
for i in[0]*input():b=[1]+map(sum,zip(b,b[1:]+[0]));a+=b,
for c in a:print" ".join("%%%ss"%len(`p`)%q for p,q in zip(b,c))
133 symbols python2
Fri Sep 16 05:26:31 2016 Sait2000
a=b=[]
for i in range(input()):b=[1]+map(sum,zip(b,b[1:]+[0]));a+=b,
for c in a:print" ".join("%%%ss"%len(`p`)%q for p,q in zip(b,c))
138 symbols python2
Fri Sep 16 05:16:40 2016 Sait2000
a=[]
for i in range(input()):b=[1]+[sum(b[x:x+2])for x in range(i)];a+=b,
for c in a:print" ".join("%%%ss"%len(`p`)%q for p,q in zip(b,c))
140 symbols python2
Fri Sep 16 05:11:10 2016 Sait2000
a=b=[]
for i in range(input()):b=[1]+[sum(b[x:x+2])for x in range(i)];a+=b,
for c in a:print" ".join("%%%ss"%len(`p`)%q for p,q in zip(b,c))
142 symbols python2
Fri Sep 16 04:56:16 2016 Sait2000
r=range
a=[]
a+=([1]+[sum(a[-1][x:x+2])for x in r(i)]for i in r(input()))
for b in a:print" ".join("%%%ss"%len(`p`)%q for p,q in zip(a[-1],b))

View all solutions