1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
<exercise name = "Fibonacci numbers">
<desc>Write a function <code>fib(n)</code> which returns the nth fibonacci
number.</desc>
<partial>
<![CDATA[
def fib(n):
# Write your function here.
]]>
</partial>
<solution>
<![CDATA[
def fib(n):
import numpy
return int((numpy.matrix([[0, 1], [1, 1]], dtype='object')**(n-1))[1,1])
]]>
</solution>
<case name="Low n" function="fib">
<arg value="10" />
<function desc="Match">int</function>
</case>
<case name="First number" function="fib">
<arg value="1" />
<function desc="Match">int</function>
</case>
<case name="Zeroth number" function="fib">
<file name="patch.py">
<![CDATA[
fib_zero = 0
]]>
</file>
<arg value="0" />
<function desc="Match">int</function>
</case>
<case name="High number" function="fib">
<arg value="30" />
<function desc="Match">int</function>
</case>
<case name="Very high number" function="fib">
<arg value="1000" />
<function desc="Match">int</function>
</case>
</exercise>
|