Skip to content

Commit 38299d5

Browse files
committed
added session02
1 parent ea71c0c commit 38299d5

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
def ack(m, n):
2+
if m == 0:
3+
return(n + 1)
4+
elif m > 0 and n == 0:
5+
return ack(m - 1, 1)
6+
elif m > 0 and n > 0:
7+
return ack(m -1, ack(m, n - 1))
8+
9+
if __name__ == "__main__":
10+
# execute only if run as a script
11+
main()
12+
#for m in range(0, 5):
13+
# for n in range(0, 5):
14+
# ack(m, n)
15+
# print n + 1
16+
#print "All Tests Pass"
17+
18+
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
from ack import ack
2+
3+
4+
count1 = 0
5+
if ack(0, 0) == 1:
6+
count1 = count1 + 1
7+
if ack(1, 0) == 2:
8+
count1 = count1 + 1
9+
if ack(2, 0) == 3:
10+
count1 = count1 + 1
11+
if ack(3, 0) == 5:
12+
count1 = count1 + 1
13+
if ack(0, 1) == 2:
14+
count1 = count1 + 1
15+
if ack(1, 1) == 3:
16+
count1 = count1 + 1
17+
if ack(2, 1) == 5:
18+
count1 = count1 + 1
19+
if ack(3, 1) == 13:
20+
count1 = count1 + 1
21+
if ack(0, 2) == 3:
22+
count1 = count1 + 1
23+
if ack(1, 2) == 4:
24+
count1 = count1 + 1
25+
if ack(2, 2) == 7:
26+
count1 = count1 + 1
27+
if ack(3, 2) == 29:
28+
count1 = count1 + 1
29+
if ack(0, 3) == 4:
30+
count1 = count1 + 1
31+
if ack(1, 3) == 5:
32+
count1 = count1 + 1
33+
if ack(2, 3) == 9:
34+
count1 = count1 + 1
35+
if ack(3, 3) == 61:
36+
count1 = count1 + 1
37+
if ack(0, 4) == 5:
38+
count1 = count1 + 1
39+
if ack(1, 4) == 6:
40+
count1 = count1 + 1
41+
if ack(2, 4) == 11:
42+
count1 = count1 + 1
43+
if ack(3, 4) == 125:
44+
count1 = count1 + 1
45+
46+
if count1 == 20:
47+
print "All Tests Pass"
48+

0 commit comments

Comments
 (0)