# C1.sage: ExpMath class of Jan. 24, 2013
# Getting Started
def z():
"""
The function z does absolutely nothing
Authors: Edinah Koffi Gnang
"""
print ''
def f2(n):
"""
Inputs an integer n and outputs 0 if n is a loosing position
(again a player who is more than five-year old and with an IQ>80)
and 1 if it a winning position in a penny removing game, where a
legal move consists of removing one or two pennies n -> (n-1) OR (n-2)
sage:f2(3)
0
Authors: Edinah Koffi Gnang
"""
if n <= 0:
return 0
elif f2(n-1) == 1 and f2(n-2) == 1:
return 0
else:
return 1
def fk(k, n):
"""
Input a positive integers k and n and outputs
0 (1) if in a game of removing 1,2,...,k pennies
is a losing (winning position)
sage:fk(2,3)
0
Authors: Edinah Koffi Gnang
"""
if n <= 0:
return 0
elif Set([fk(k,n-i) for i in range(1,k+1)]) == Set([1]):
return 0
else:
return 1
def fL(L, n):
"""
Inputs a list of positive intgers S and an integers n and outputs
0 (1) if in a game of removing a member of S pennies is a loosing
(winning position)
sage :fL([1, 2, 3], 5)
"""
if n <= 0:
return 0
elif Set([fL(L, n-i) for i in L]) == Set([1]):
return 0
else :
return 1