Skip to content

Commit 9646723

Browse files
committed
2 parents 00358c7 + 88ec24e commit 9646723

9 files changed

Lines changed: 816 additions & 0 deletions

File tree

‎Students/alexg/session02/ack.py‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/python
2+
3+
def ack(m,n):
4+
"""Returns the output of the Ackerman Function"""
5+
if m<0 or n<0:
6+
return None
7+
elif not m:
8+
return n+1
9+
elif m>0 and not n:
10+
return ack(m-1,1)
11+
elif m>0 and n>0:
12+
return ack(m-1, ack(m,n-1))
13+
14+
if __name__ == "__main__":
15+
assert ack(0,0)==1
16+
assert ack(0,1)==2
17+
assert ack(0,2)==3
18+
assert ack(0,3)==4
19+
assert ack(0,4)==5
20+
assert ack(1,0)==2
21+
assert ack(1,2)==4
22+
assert ack(1,3)==5
23+
assert ack(1,4)==6
24+
assert ack(2,0)==3
25+
assert ack(2,1)==5
26+
assert ack(2,2)==7
27+
assert ack(2,3)==9
28+
assert ack(2,4)==11
29+
assert ack(3,0)==5
30+
assert ack(3,1)==13
31+
assert ack(3,2)==29
32+
assert ack(3,3)==61
33+
assert ack(3,4)==125
34+
print "All Tests Pass"

‎Students/alexg/session02/series.py‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/python
2+
3+
def fibonacci(x):
4+
"""Returns the nth value of the Fibonacci Series"""
5+
if not x:
6+
return 0
7+
elif x == 1:
8+
return 1
9+
else:
10+
return fibonacci(x-1)+fibonacci(x-2)
11+
12+
def lucas(x):
13+
"""Returns the nth value of the Lucas Series"""
14+
if not x:
15+
return 2
16+
elif x == 1:
17+
return 1
18+
else:
19+
return lucas(x-1)+lucas(x-2)
20+
21+
def sum_series(n,x=0,y=1):
22+
"""Returns the nth value of either series, or creates a new one"""
23+
if x==0 and y==1:
24+
return fibonacci(n)
25+
elif x==2 and y==1:
26+
return lucas(n)
27+
else:
28+
if not n:
29+
return x
30+
elif n==1:
31+
return y
32+
else:
33+
return sum_series(n-1)+sum_series(n-2)
34+
35+
if __name__ == "__main__":
36+
#Testing the 7th value of the fibonacci sequence
37+
assert fibonacci(6)==8
38+
39+
#Testing the 7th value of the lucas sequence
40+
assert lucas(6)==18
41+
42+
#Testing for the 2nd value of the new function
43+
assert sum_series(9,40,2)==34

‎Students/brydavis/start‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env bash
2+
3+
4+
# # Set aliases
5+
# alias ux='chmod u+x';
6+
# alias ax='chmod a+x';
7+
8+
9+
# # Begin work session
10+
git checkout master;
11+
git fetch upstream master;
12+
git merge upstream/master;
13+
git push;
14+
15+
16+
# Print when ready to develop
17+
git status;
18+
echo;
19+
echo 'Ready to develop!';
20+
echo 'Please proceed...';
21+
22+
23+
commit_work () {
24+
git commit -m 'another update';
25+
git push;
26+
}
27+
28+
# # End work session
29+
end_work () {
30+
echo 'Pusing git...';
31+
git push origin master;
32+
echo 'Push complete!';
33+
echo 'Goodbye ~';
34+
}
35+
36+
37+
alias endwork=end_work;
38+
39+
40+
41+

0 commit comments

Comments
 (0)