koutch commited on
Commit
fed9c8f
·
1 Parent(s): 7845d61

Update data content

Browse files
README.md CHANGED
@@ -22,13 +22,13 @@ dataset_info:
22
  dtype: int32
23
  splits:
24
  - name: train
25
- num_bytes: 3659774
26
- num_examples: 6117
27
  - name: test
28
- num_bytes: 6443452
29
- num_examples: 9885
30
- download_size: 12774289
31
- dataset_size: 10103226
32
  - config_name: singapore_data
33
  features:
34
  - name: submission_id
@@ -112,13 +112,13 @@ dataset_info:
112
  dtype: string
113
  splits:
114
  - name: train
115
- num_bytes: 17562
116
- num_examples: 30
117
  - name: test
118
- num_bytes: 15342
119
- num_examples: 26
120
- download_size: 37317
121
- dataset_size: 32904
122
  - config_name: singapore_metadata
123
  features:
124
  - name: assignment_id
 
22
  dtype: int32
23
  splits:
24
  - name: train
25
+ num_bytes: 4435051
26
+ num_examples: 8048
27
  - name: test
28
+ num_bytes: 7636303
29
+ num_examples: 16437
30
+ download_size: 16145032
31
+ dataset_size: 12071354
32
  - config_name: singapore_data
33
  features:
34
  - name: submission_id
 
112
  dtype: string
113
  splits:
114
  - name: train
115
+ num_bytes: 15852
116
+ num_examples: 25
117
  - name: test
118
+ num_bytes: 14263
119
+ num_examples: 24
120
+ download_size: 34000
121
+ dataset_size: 30115
122
  - config_name: singapore_metadata
123
  features:
124
  - name: assignment_id
data/dublin_data_test.jsonl CHANGED
The diff for this file is too large to render. See raw diff
 
data/dublin_data_train.jsonl CHANGED
The diff for this file is too large to render. See raw diff
 
data/dublin_metadata_test.jsonl CHANGED
@@ -1,26 +1,24 @@
1
- {"assignment_id":"reverse.py_ca277_reverse","func_name":"reverse","reference_solution":"def reverse(a):\n b=[]\n i=0\n while i < len(a):\n b.append(a[len(a)-1-i])\n i = i + 1\n return b","description":"Reverse a list of elements.","test":"assert reverse([])==[] and reverse([20, 10, 0, -10, -20])==[-20, -10, 0, 10, 20] and reverse(['toto', True, [10, 0, 9], 12.8, 6])==[6, 12.8, [10, 0, 9], True, 'toto']"}
2
- {"assignment_id":"func_selection_sort.py_ca116_selection_sort","func_name":"selection_sort","reference_solution":"def selection_sort(a):\n\ti=0\n\twhile i<len(a):\n\t\tp=i\n\t\tj=i+1\n\t\twhile j < len(a):\n\t\t\tif a[j] < a[p] :\n\t\t\t\tp=j\n\t\t\tj=j+1\n\t\ttmp=a[p]\n\t\ta[p]=a[i]\n\t\ta[i]=tmp\n\t\ti=i+1\n\treturn a\n\n","description":"Repeatedly move minimimum of remaining sublist to front.","test":"assert selection_sort([])==[] and selection_sort([0])==[0] and selection_sort([25204, -1, -18176])==[-18176, -1, 25204] and selection_sort([-18176, -1, 25204])==[-18176, -1, 25204]"}
3
- {"assignment_id":"func_reverse.py_ca116_reverse","func_name":"reverse","reference_solution":"def reverse(a):\n b=[]\n i=0\n while i < len(a):\n b.append(a[len(a)-1-i])\n i = i + 1\n return b","description":"Reverse a list of elements.","test":"assert reverse([])==[] and reverse([0])==[0] and reverse([-103, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, 1867157052])==[1867157052, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, -103] and reverse([-103, 113466788817036974729578468346735566318, 31758, 1867157052, 10933, -70, 1867157052])==[1867157052, -70, 10933, 1867157052, 31758, 113466788817036974729578468346735566318, -103] and reverse([1867157052, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, -103])==[-103, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, 1867157052] and reverse([1867157052, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, -103])==[-103, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, 1867157052] and reverse([-103, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, 1867157052])==[1867157052, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, -103] and reverse([[1]])==[[1]]"}
4
- {"assignment_id":"func_bsearch.py_ca116_bsearch","func_name":"bsearch","reference_solution":"def bsearch(a, q):\n low = 0\n high = len(a)\n while low < high:\n mid = (low + high) \/\/ 2\n if a[mid] < q:\n low = mid + 1\n else:\n high = mid\n return low","description":"Search for an element in an array using the binary search algorithm.","test":"assert bsearch([],12)==0 and bsearch([1, 2, 3, 4, 6, 7, 8],5)==4 and bsearch([1, 2, 3, 4, 6, 7, 8],1)==0 and bsearch([1, 2, 3, 4, 6, 7, 8],4)==3"}
5
- {"assignment_id":"count_102.py_ca117_count_letters","func_name":"count_letters","reference_solution":"def count_letters(s):\n if not s:\n return 0\n return 1 + count_letters(s[1:])\n","description":"Return the number of lettres in a string.","test":"assert count_letters('')==0 and count_letters('0')==1 and count_letters('##')==2 and count_letters('t')==1 and count_letters('fqfseqfseqsse')==13"}
6
- {"assignment_id":"fibonacci_102.py_ca117_fibonacci","func_name":"fibonacci","reference_solution":"def fibonacci(n):\n if n == 0:\n return 1\n if n == 1:\n return 1\n return fibonacci(n-1) + fibonacci(n-2)\n","description":"Return the value of the fibonacci series at position n.","test":"assert fibonacci(0)==1 and fibonacci(1)==1 and fibonacci(2)==2 and fibonacci(10)==89 and fibonacci(23)==46368"}
7
- {"assignment_id":"maximum_102.py_ca117_maximum","func_name":"maximum","reference_solution":"def maximum(l):\n if len(l) == 1:\n return l[0]\n tail_max = maximum(l[1:])\n return l[0] if l[0] > tail_max else tail_max\n # Could do this but ought not use max I suppose...\n # return max(l[0], maximum(l[1:]))\n","description":"Return the maximum element in a list of numbers.","test":"assert maximum([0])==0 and maximum([67, 1, 2, -2, 0])==67 and maximum([0, -2, 2, 1, 67])==67 and maximum([-10, -23, -45, -9, -45617])==-9"}
8
- {"assignment_id":"minimum_102.py_ca117_minimum","func_name":"minimum","reference_solution":"def minimum(l):\n if len(l) == 1:\n return l[0]\n tail_min = minimum(l[1:])\n return l[0] if l[0] < tail_min else tail_min\n # Could do this but ought not use min I suppose...\n # return min(l[0], rmin(l[1:]))\n","description":"Return the minimum element in a list of numbers.","test":"assert minimum([0])==0 and minimum([2, 10, 23, 9, 187])==2 and minimum([-2, -26, 7, -123, -1236521])==-1236521 and minimum([3896, 3673, 45, 16715, 23673])==45"}
9
- {"assignment_id":"reverse_102.py_ca117_reverse_list","func_name":"reverse_list","reference_solution":"def reverse_list(l):\n if l == []:\n return []\n return reverse_list(l[1:]) + [l[0]]\n # temp = reverse(l[1:])\n # temp.append(l[0])\n # return temp\n # note we cannot use return reverse(l[1:]).append(l[0]) because append()\n # does not return anything\n","description":"Reverse a list of elements.","test":"assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]"}
10
- {"assignment_id":"selection_sort.py_ca277_sort","func_name":"sort","reference_solution":"def swap(a, i, j):\n tmp = a[i]\n a[i] = a[j]\n a[j] = tmp\n\n\ndef find_position_of_smallest(a, i):\n p = i \n while i < len(a):\n if a[i] < a[p]:\n p = i\n i = i + 1\n return p\t\n \n\ndef sort(a):\n i = 0\n while i < len(a):\n p = find_position_of_smallest(a,i) \n swap(a, i, p)\n i = i + 1\n","description":"Repeatedly move minimimum of remaining sublist to front.","test":"assert sort([0])==None and sort([0])==None and sort([])==None and sort([])==None and sort([' '])==None and sort([' '])==None and sort([70, 339305549])==None and sort([70, 339305549])==None"}
11
- {"assignment_id":"sets.py_ca277_union","func_name":"union","reference_solution":"def union(a, b):\n\tc=[]\n\ti = 0\n\twhile i < len(a):\n\t\tif a[i] not in c:\n\t\t\tc.append(a[i])\n\t\ti = i + 1\n\n\tp = 0\n\twhile p < len(b):\n\t\tif b[p] not in c:\n\t\t\tc.append(b[p])\n\t\tp = p + 1\n\n\treturn c\n\n","description":"Merge two lists into a single one.","test":"assert union([],[])==[] and union([25785],[25785])==[25785] and union([-90, 21135, 29310, -8059, 7114, -90, -5808, 1333, -18691, 7, -19450, 67745575129021321678860432754396203799, -9288, -161403197171354040520992237328119268342, 49, 120528818203287557, 133011337445419463191476642795673848676, 11952, 11996],[5, -9316, 7379237229304681733])==[-90, 21135, 29310, -8059, 7114, -5808, 1333, -18691, 7, -19450, 67745575129021321678860432754396203799, -9288, -161403197171354040520992237328119268342, 49, 120528818203287557, 133011337445419463191476642795673848676, 11952, 11996, 5, -9316, 7379237229304681733]"}
12
- {"assignment_id":"sets.py_ca277_intersection","func_name":"intersection","reference_solution":"def intersection(a, b):\n\td=[]\n\ti = 0\n\twhile i < len(a):\n\t\tif a[i] in b and a[i] not in d:\n\t\t\td.append(a[i])\n\t\ti = i + 1\n\n\treturn d","description":"Return the elements which are in both lists.","test":"assert intersection([],[])==[] and intersection([20052, 20052, -9991],[102, 20052, -9991])==[20052, -9991] and intersection([38908273694008580353068229963801163341, 59, 38908273694008580353068229963801163341, -38, 28239, -2723, 24559, -5794],[38908273694008580353068229963801163341, 59, 38908273694008580353068229963801163341, -38, 28239, -2723, 24559, -5794])==[38908273694008580353068229963801163341, 59, -38, 28239, -2723, 24559, -5794]"}
13
- {"assignment_id":"swap_v1_042.py_ca117_swap_keys_values","func_name":"swap_keys_values","reference_solution":"def swap_keys_values(d):\n return dict([(v, k) for (k, v) in list(d.items())])\n","description":"Swap keys with values.","test":"assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'}"}
14
- {"assignment_id":"swap_v2_042.py_ca117_swap_unique_keys_values","func_name":"swap_unique_keys_values","reference_solution":"def swap_unique_keys_values(d):\n # Have to explicitly convert dict_view type to list type in Python 3\n return dict([(v, k) for (k, v) in list(d.items()) if list(d.values()).count(v) == 1])\n","description":"Swap keys with unique values.","test":"assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'}"}
15
- {"assignment_id":"funcs04.py_ca278_merge_lists","func_name":"merge_lists","reference_solution":"def merge_lists(l1,l2):\n '''take two lists l1 and l2 and return a third list which contains \n every second element of l1 and l2'''\n l3 = []\n i = 0\n while i < len(l1):\n l3.append(l1[i])\n i += 2\n i = 0\n while i < len(l2):\n l3.append(l2[i])\n i += 2\n return l3\n\n","description":"Obtain every second element of l1 and l2.","test":"assert merge_lists([],[])==[] and merge_lists([],[1, 2, 3, 4])==[1, 3] and merge_lists([1, 2, 3, 4],[])==[1, 3] and merge_lists([10, 20, 45, 2, -10987, 89165],[9, 0, -6754, 5625264, 8765])==[10, 45, -10987, 9, -6754, 8765]"}
16
- {"assignment_id":"funcs04.py_ca278_remove_zeros","func_name":"remove_zeros","reference_solution":"def remove_zeros(list):\n '''take a list of numbers and remove zeros from the list'''\n while 0 in list:\n list.remove(0)\n\n","description":"Remove zeros from list.","test":"assert remove_zeros([])==None and remove_zeros([])==None and remove_zeros([5202, -24344, -6528])==None and remove_zeros([5202, -24344, -6528])==None"}
17
- {"assignment_id":"circle_062.py_ca117_overlap","func_name":"overlap","reference_solution":"def overlap(x1=0, y1=0, r1=1, x2=0, y2=0, r2=1):\n d = ((x2-x1)**2 + (y2-y1)**2)**0.5\n if d < r1 + r2:\n return True\n return False\n\n","description":"Test if two circles overlap.","test":"assert overlap(12,-6058,21436,-3483096651887624530,24,31017)==False and overlap(-30592,-26624,-11905,1,2,30134)==False and overlap(0,0,0,0,0,0)==False and overlap(5128,-8635,-28938,25,-31295,-21637807133189218411179185993653430151)==False and overlap(-16348,-2218,2871,-15155,-83,24475)==True and overlap(4807,1216206119,8753907074291481720,-19844,-26061,-15639)==True and overlap(1348593950,19232,-10923,20,2259187900768772679,-5343103208648864320)==False and overlap(8410739119977124611,9995,83,8410739119977124611,19348,21604)==True"}
18
- {"assignment_id":"mutable_062.py_ca117_append2list","func_name":"append2list","reference_solution":"def append2list(l1, l2=None):\n if l2 == None:\n l2 = []\n for i in l1:\n l2.append(i)\n return l2\n\n","description":"Append l1 to l2. If l2 not supplied default to empty list.","test":"assert append2list([-12248, -4743, -25, -6030600119498841921, -8866],[-16276, 117, -12248, -4743, -25, -6030600119498841921, -8866])==[-16276, 117, -12248, -4743, -25, -6030600119498841921, -8866, -12248, -4743, -25, -6030600119498841921, -8866] and append2list([-12248, -4743, -25, -6030600119498841921, -8866],[-16276, 117, -12248, -4743, -25, -6030600119498841921, -8866, -12248, -4743, -25, -6030600119498841921, -8866])==[-16276, 117, -12248, -4743, -25, -6030600119498841921, -8866, -12248, -4743, -25, -6030600119498841921, -8866, -12248, -4743, -25, -6030600119498841921, -8866] and append2list([-12248, -4743, -25, -6030600119498841921, -8866, -16276, 117, -12248, -4743, -25, -6030600119498841921, -8866, -12248, -4743, -25, -6030600119498841921, -8866],[-16276, 117, -12248, -4743, -25, -6030600119498841921, -8866, -12248, -4743, -25, -6030600119498841921, -8866])==[-16276, 117, -12248, -4743, -25, -6030600119498841921, -8866, -12248, -4743, -25, -6030600119498841921, -8866, -12248, -4743, -25, -6030600119498841921, -8866, -16276, 117, -12248, -4743, -25, -6030600119498841921, -8866, -12248, -4743, -25, -6030600119498841921, -8866] and append2list([-21267],[-21267, -21267])==[-21267, -21267, -21267]"}
19
- {"assignment_id":"iterative07.py_ca278_search","func_name":"search","reference_solution":"def search(str,letter):\n '''returns True if letter is in str, False if it is not there'''\n i = 0\n while i < len(str):\n if letter == str[i]:\n return True\n i = i + 1\n return False\n\n","description":"Return whether a letter is part of a string","test":"assert search('','0')==False and search('0','0')==True and search('ERFE0Rfsef','0')==True and search('ERFERfsef0','0')==True and search('','a')==False and search('cbzeycuzbvyzuvb','a')==False and search('cbsducsvdbcyts','c')==True and search('dbzeducvbzy','y')==True and search('xqvsgxcutvy','u')==True"}
20
- {"assignment_id":"iterative07.py_ca278_index","func_name":"index","reference_solution":"def index(str,letter):\n '''returns the position of letter in str, -1 if it is not there'''\n i = 0\n while i < len(str):\n if letter == str[i]:\n return i\n i = i + 1\n return -1\n\n\n","description":"Returns the position of letter in str, -1 if it is not there.","test":"assert index('','0')==-1 and index('0','0')==0 and index('11','1')==0"}
21
- {"assignment_id":"iterative07.py_ca278_fibonacci","func_name":"fibonacci","reference_solution":"def fibonacci(n):\n '''returns the value of the fibonacci series at position n'''\n if n == 0:\n return 0\n if n == 1:\n return 1\n else:\n fibN_2 = 0\n fibN_1 = 1\n i = 2\n while i <=n:\n fibN = fibN_2 + fibN_1\n fibN_2 = fibN_1\n fibN_1 = fibN\n i = i + 1\n return fibN\n\n","description":"Return the value of the fibonacci series at position n.","test":"assert fibonacci(0)==0 and fibonacci(1)==1 and fibonacci(2)==1 and fibonacci(10)==55 and fibonacci(23)==28657"}
22
- {"assignment_id":"recursive07.py_ca278_search","func_name":"search","reference_solution":"def search(str,letter):\n '''returns True if letter is in str, False otherwise'''\n if str == \"\":\n return False\n elif str[0] == letter:\n return True\n else:\n #keep looking\n return search(str[1:],letter)\n \n\n","description":"Return whether a letter is part of a string","test":"assert search('','0')==False and search('0','0')==True and search('ERFE0Rfsef','0')==True and search('ERFERfsef0','0')==True and search('','a')==False and search('cbzeycuzbvyzuvb','a')==False and search('cbsducsvdbcyts','c')==True and search('dbzeducvbzy','y')==True and search('xqvsgxcutvy','u')==True"}
23
- {"assignment_id":"recursive07.py_ca278_index","func_name":"index","reference_solution":"def index(str,letter,pos):\n '''returns the position of letter in str, -1 if it is not there'''\n if pos == len(str):\n return -1\n elif str[pos] == letter:\n return pos\n else:\n return index(str,letter,pos+1)\n\n\n","description":"Return the position of letter in str, -1 if it is not there.","test":"assert index('','0',0)==-1 and index('0','0',0)==0 and index('a','8',0)==-1 and index('tV2','2',0)==2"}
24
- {"assignment_id":"recursive07.py_ca278_fibonacci","func_name":"fibonacci","reference_solution":"def fibonacci(n):\n '''returns the value of the fibonacci series at position n'''\n if n == 0:\n return 0\n elif n == 1:\n return 1\n else:\n return fibonacci(n-1) + fibonacci(n-2)\n\n","description":"Return the value of the fibonacci series at position n.","test":"assert fibonacci(0)==0 and fibonacci(1)==1 and fibonacci(2)==1 and fibonacci(10)==55 and fibonacci(23)==28657"}
25
- {"assignment_id":"factorial_102.py_ca117_factorial","func_name":"factorial","reference_solution":"def factorial(n):\n\tif n < 2:\n\t\treturn 1\n\treturn n * factorial(n-1)","description":"Return the factorial of a number.","test":"assert factorial(-1)==1 and factorial(0)==1 and factorial(1)==1 and factorial(2)==2 and factorial(5)==120 and factorial(20)==2432902008176640000"}
26
- {"assignment_id":"sumup_102.py_ca117_sumup","func_name":"sumup","reference_solution":"def sumup(n):\n\tif n < 2:\n\t\treturn n\n\tsum_to_n = sumup(n-1)\n\treturn n + sum_to_n","description":"Return the sum of all integers up to n.","test":"assert sumup(0)==0 and sumup(1)==1 and sumup(2)==3 and sumup(10)==55 and sumup(27)==378"}
 
1
+ {"assignment_id":"reverse_iter","func_name":"reverse","reference_solution":"def reverse(a):\n b=[]\n i=0\n while i < len(a):\n b.append(a[len(a)-1-i])\n i = i + 1\n return b","description":"Iteratively reverse a list of elements.","test":"assert reverse([])==[] and reverse([20, 10, 0, -10, -20])==[-20, -10, 0, 10, 20] and reverse(['toto', True, [10, 0, 9], 12.8, 6])==[6, 12.8, [10, 0, 9], True, 'toto']"}
2
+ {"assignment_id":"selection_sort","func_name":"selection_sort","reference_solution":"def selection_sort(a):\n\ti=0\n\twhile i<len(a):\n\t\tp=i\n\t\tj=i+1\n\t\twhile j < len(a):\n\t\t\tif a[j] < a[p] :\n\t\t\t\tp=j\n\t\t\tj=j+1\n\t\ttmp=a[p]\n\t\ta[p]=a[i]\n\t\ta[i]=tmp\n\t\ti=i+1\n\treturn a\n\n","description":"Sort a list by repeatedly move minimimum of remaining sublist to front.","test":"assert selection_sort([])==[] and selection_sort([0])==[0] and selection_sort([25204, -1, -18176])==[-18176, -1, 25204] and selection_sort([-18176, -1, 25204])==[-18176, -1, 25204]"}
3
+ {"assignment_id":"reverse_by_swap","func_name":"reverse","reference_solution":"def reverse(a):\n b=[]\n i=0\n while i < len(a):\n b.append(a[len(a)-1-i])\n i = i + 1\n return b","description":"Reverse a list of elements by swapping its elements.","test":"assert reverse([])==[] and reverse([0])==[0] and reverse([-103, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, 1867157052])==[1867157052, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, -103] and reverse([-103, 113466788817036974729578468346735566318, 31758, 1867157052, 10933, -70, 1867157052])==[1867157052, -70, 10933, 1867157052, 31758, 113466788817036974729578468346735566318, -103] and reverse([1867157052, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, -103])==[-103, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, 1867157052] and reverse([1867157052, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, -103])==[-103, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, 1867157052] and reverse([-103, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, 1867157052])==[1867157052, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, -103] and reverse([[1]])==[[1]]"}
4
+ {"assignment_id":"bsearch","func_name":"bsearch","reference_solution":"def bsearch(a, q):\n low = 0\n high = len(a)\n while low < high:\n mid = (low + high) \/\/ 2\n if a[mid] < q:\n low = mid + 1\n else:\n high = mid\n return low","description":"Search for element q in the sorted array a.","test":"assert bsearch([],12)==0 and bsearch([1, 2, 3, 4, 6, 7, 8],5)==4 and bsearch([1, 2, 3, 4, 6, 7, 8],1)==0 and bsearch([1, 2, 3, 4, 6, 7, 8],4)==3"}
5
+ {"assignment_id":"count_letters","func_name":"count_letters","reference_solution":"def count_letters(s):\n if not s:\n return 0\n return 1 + count_letters(s[1:])\n","description":"Return the number of lettres in a string.","test":"assert count_letters('')==0 and count_letters('0')==1 and count_letters('##')==2 and count_letters('t')==1 and count_letters('fqfseqfseqsse')==13"}
6
+ {"assignment_id":"maximum","func_name":"maximum","reference_solution":"def maximum(l):\n if len(l) == 1:\n return l[0]\n tail_max = maximum(l[1:])\n return l[0] if l[0] > tail_max else tail_max\n # Could do this but ought not use max I suppose...\n # return max(l[0], maximum(l[1:]))\n","description":"Return the maximum element in a list of numbers.","test":"assert maximum([0])==0 and maximum([67, 1, 2, -2, 0])==67 and maximum([0, -2, 2, 1, 67])==67 and maximum([-10, -23, -45, -9, -45617])==-9"}
7
+ {"assignment_id":"minimum","func_name":"minimum","reference_solution":"def minimum(l):\n if len(l) == 1:\n return l[0]\n tail_min = minimum(l[1:])\n return l[0] if l[0] < tail_min else tail_min\n # Could do this but ought not use min I suppose...\n # return min(l[0], rmin(l[1:]))\n","description":"Return the minimum element in a list of numbers.","test":"assert minimum([0])==0 and minimum([2, 10, 23, 9, 187])==2 and minimum([-2, -26, 7, -123, -1236521])==-1236521 and minimum([3896, 3673, 45, 16715, 23673])==45"}
8
+ {"assignment_id":"reverse_recur","func_name":"reverse_list","reference_solution":"def reverse_list(l):\n if l == []:\n return []\n return reverse_list(l[1:]) + [l[0]]\n # temp = reverse(l[1:])\n # temp.append(l[0])\n # return temp\n # note we cannot use return reverse(l[1:]).append(l[0]) because append()\n # does not return anything\n","description":"Recursively reverse a list of elements.","test":"assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]"}
9
+ {"assignment_id":"sort","func_name":"sort","reference_solution":"def swap(a, i, j):\n tmp = a[i]\n a[i] = a[j]\n a[j] = tmp\n\n\ndef find_position_of_smallest(a, i):\n p = i \n while i < len(a):\n if a[i] < a[p]:\n p = i\n i = i + 1\n return p\t\n \n\ndef sort(a):\n i = 0\n while i < len(a):\n p = find_position_of_smallest(a,i) \n swap(a, i, p)\n i = i + 1\n","description":"Sort a list by repeatedly moving the minimimum of the remaining sublist to the front.","test":"assert sort([0])==None and sort([0])==None and sort([])==None and sort([])==None and sort([' '])==None and sort([' '])==None and sort([70, 339305549])==None and sort([70, 339305549])==None"}
10
+ {"assignment_id":"union","func_name":"union","reference_solution":"def union(a, b):\n\tc=[]\n\ti = 0\n\twhile i < len(a):\n\t\tif a[i] not in c:\n\t\t\tc.append(a[i])\n\t\ti = i + 1\n\n\tp = 0\n\twhile p < len(b):\n\t\tif b[p] not in c:\n\t\t\tc.append(b[p])\n\t\tp = p + 1\n\n\treturn c\n\n","description":"Merge two lists into a single one.","test":"assert union([],[])==[] and union([25785],[25785])==[25785] and union([-90, 21135, 29310, -8059, 7114, -90, -5808, 1333, -18691, 7, -19450, 67745575129021321678860432754396203799, -9288, -161403197171354040520992237328119268342, 49, 120528818203287557, 133011337445419463191476642795673848676, 11952, 11996],[5, -9316, 7379237229304681733])==[-90, 21135, 29310, -8059, 7114, -5808, 1333, -18691, 7, -19450, 67745575129021321678860432754396203799, -9288, -161403197171354040520992237328119268342, 49, 120528818203287557, 133011337445419463191476642795673848676, 11952, 11996, 5, -9316, 7379237229304681733]"}
11
+ {"assignment_id":"intersection","func_name":"intersection","reference_solution":"def intersection(a, b):\n\td=[]\n\ti = 0\n\twhile i < len(a):\n\t\tif a[i] in b and a[i] not in d:\n\t\t\td.append(a[i])\n\t\ti = i + 1\n\n\treturn d","description":"Return the intersection between two lists.","test":"assert intersection([],[])==[] and intersection([20052, 20052, -9991],[102, 20052, -9991])==[20052, -9991] and intersection([38908273694008580353068229963801163341, 59, 38908273694008580353068229963801163341, -38, 28239, -2723, 24559, -5794],[38908273694008580353068229963801163341, 59, 38908273694008580353068229963801163341, -38, 28239, -2723, 24559, -5794])==[38908273694008580353068229963801163341, 59, -38, 28239, -2723, 24559, -5794]"}
12
+ {"assignment_id":"swap_keys_values","func_name":"swap_keys_values","reference_solution":"def swap_keys_values(d):\n return dict([(v, k) for (k, v) in list(d.items())])\n","description":"Swap the keys of a dictionary with its values.","test":"assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'}"}
13
+ {"assignment_id":"merge_lists","func_name":"merge_lists","reference_solution":"def merge_lists(l1,l2):\n '''take two lists l1 and l2 and return a third list which contains \n every second element of l1 and l2'''\n l3 = []\n i = 0\n while i < len(l1):\n l3.append(l1[i])\n i += 2\n i = 0\n while i < len(l2):\n l3.append(l2[i])\n i += 2\n return l3\n\n","description":"Take two lists l1 and l2 and return a third list which contains every second element of l1 and l2.","test":"assert merge_lists([],[])==[] and merge_lists([],[1, 2, 3, 4])==[1, 3] and merge_lists([1, 2, 3, 4],[])==[1, 3] and merge_lists([10, 20, 45, 2, -10987, 89165],[9, 0, -6754, 5625264, 8765])==[10, 45, -10987, 9, -6754, 8765]"}
14
+ {"assignment_id":"remove_zeros","func_name":"remove_zeros","reference_solution":"def remove_zeros(list):\n '''take a list of numbers and remove zeros from the list'''\n while 0 in list:\n list.remove(0)\n\n","description":"Take a list of numbers and removes the zeros from it.","test":"assert remove_zeros([])==None and remove_zeros([])==None and remove_zeros([5202, -24344, -6528])==None and remove_zeros([5202, -24344, -6528])==None"}
15
+ {"assignment_id":"overlap","func_name":"overlap","reference_solution":"def overlap(x1=0, y1=0, r1=1, x2=0, y2=0, r2=1):\n d = ((x2-x1)**2 + (y2-y1)**2)**0.5\n if d < r1 + r2:\n return True\n return False\n\n","description":"Test if two circles overlap.","test":"assert overlap(12,-6058,21436,-3483096651887624530,24,31017)==False and overlap(-30592,-26624,-11905,1,2,30134)==False and overlap(0,0,0,0,0,0)==False and overlap(5128,-8635,-28938,25,-31295,-21637807133189218411179185993653430151)==False and overlap(-16348,-2218,2871,-15155,-83,24475)==True and overlap(4807,1216206119,8753907074291481720,-19844,-26061,-15639)==True and overlap(1348593950,19232,-10923,20,2259187900768772679,-5343103208648864320)==False and overlap(8410739119977124611,9995,83,8410739119977124611,19348,21604)==True"}
16
+ {"assignment_id":"append2list","func_name":"append2list","reference_solution":"def append2list(l1, l2=None):\n if l2 == None:\n l2 = []\n for i in l1:\n l2.append(i)\n return l2\n\n","description":"Appends elements of a list l1 at the end of the list l2. If l2 not supplied default to empty list.","test":"assert append2list([-12248, -4743, -25, -6030600119498841921, -8866],[-16276, 117, -12248, -4743, -25, -6030600119498841921, -8866])==[-16276, 117, -12248, -4743, -25, -6030600119498841921, -8866, -12248, -4743, -25, -6030600119498841921, -8866] and append2list([-12248, -4743, -25, -6030600119498841921, -8866],[-16276, 117, -12248, -4743, -25, -6030600119498841921, -8866, -12248, -4743, -25, -6030600119498841921, -8866])==[-16276, 117, -12248, -4743, -25, -6030600119498841921, -8866, -12248, -4743, -25, -6030600119498841921, -8866, -12248, -4743, -25, -6030600119498841921, -8866] and append2list([-12248, -4743, -25, -6030600119498841921, -8866, -16276, 117, -12248, -4743, -25, -6030600119498841921, -8866, -12248, -4743, -25, -6030600119498841921, -8866],[-16276, 117, -12248, -4743, -25, -6030600119498841921, -8866, -12248, -4743, -25, -6030600119498841921, -8866])==[-16276, 117, -12248, -4743, -25, -6030600119498841921, -8866, -12248, -4743, -25, -6030600119498841921, -8866, -12248, -4743, -25, -6030600119498841921, -8866, -16276, 117, -12248, -4743, -25, -6030600119498841921, -8866, -12248, -4743, -25, -6030600119498841921, -8866] and append2list([-21267],[-21267, -21267])==[-21267, -21267, -21267]"}
17
+ {"assignment_id":"search_iter","func_name":"search","reference_solution":"def search(str,letter):\n '''returns True if letter is in str, False if it is not there'''\n i = 0\n while i < len(str):\n if letter == str[i]:\n return True\n i = i + 1\n return False\n\n","description":"Iteratively search for a letter in a string","test":"assert search('','0')==False and search('0','0')==True and search('ERFE0Rfsef','0')==True and search('ERFERfsef0','0')==True and search('','a')==False and search('cbzeycuzbvyzuvb','a')==False and search('cbsducsvdbcyts','c')==True and search('dbzeducvbzy','y')==True and search('xqvsgxcutvy','u')==True"}
18
+ {"assignment_id":"index_iter","func_name":"index","reference_solution":"def index(str,letter):\n '''returns the position of letter in str, -1 if it is not there'''\n i = 0\n while i < len(str):\n if letter == str[i]:\n return i\n i = i + 1\n return -1\n\n\n","description":"Iteratively search for the position of letter in str, return -1 if it is not there.","test":"assert index('','0')==-1 and index('0','0')==0 and index('11','1')==0"}
19
+ {"assignment_id":"fibonacci_iter","func_name":"fibonacci","reference_solution":"def fibonacci(n):\n '''returns the value of the fibonacci series at position n'''\n if n == 0:\n return 0\n if n == 1:\n return 1\n else:\n fibN_2 = 0\n fibN_1 = 1\n i = 2\n while i <=n:\n fibN = fibN_2 + fibN_1\n fibN_2 = fibN_1\n fibN_1 = fibN\n i = i + 1\n return fibN\n\n","description":"Iteratively compute the value of the fibonacci series at position n.","test":"assert fibonacci(0)==0 and fibonacci(1)==1 and fibonacci(2)==1 and fibonacci(10)==55 and fibonacci(23)==28657"}
20
+ {"assignment_id":"search_recur","func_name":"search","reference_solution":"def search(str,letter):\n '''returns True if letter is in str, False otherwise'''\n if str == \"\":\n return False\n elif str[0] == letter:\n return True\n else:\n #keep looking\n return search(str[1:],letter)\n \n\n","description":"Recursively search for a letter in a string","test":"assert search('','0')==False and search('0','0')==True and search('ERFE0Rfsef','0')==True and search('ERFERfsef0','0')==True and search('','a')==False and search('cbzeycuzbvyzuvb','a')==False and search('cbsducsvdbcyts','c')==True and search('dbzeducvbzy','y')==True and search('xqvsgxcutvy','u')==True"}
21
+ {"assignment_id":"index_recur","func_name":"index","reference_solution":"def index(str,letter,pos):\n '''returns the position of letter in str, -1 if it is not there'''\n if pos == len(str):\n return -1\n elif str[pos] == letter:\n return pos\n else:\n return index(str,letter,pos+1)\n\n\n","description":"Recursively search for the position of letter in str, return -1 if it is not there.","test":"assert index('','0',0)==-1 and index('0','0',0)==0 and index('a','8',0)==-1 and index('tV2','2',0)==2"}
22
+ {"assignment_id":"fibonacci_recur","func_name":"fibonacci","reference_solution":"def fibonacci(n):\n '''returns the value of the fibonacci series at position n'''\n if n == 0:\n return 0\n elif n == 1:\n return 1\n else:\n return fibonacci(n-1) + fibonacci(n-2)\n\n","description":"Recursively compute the value of the fibonacci series at position n.","test":"assert fibonacci(0)==0 and fibonacci(1)==1 and fibonacci(2)==1 and fibonacci(10)==55 and fibonacci(23)==28657"}
23
+ {"assignment_id":"factorial","func_name":"factorial","reference_solution":"def factorial(n):\n\tif n < 2:\n\t\treturn 1\n\treturn n * factorial(n-1)","description":"Compute the factorial of the given number.","test":"assert factorial(-1)==1 and factorial(0)==1 and factorial(1)==1 and factorial(2)==2 and factorial(5)==120 and factorial(20)==2432902008176640000"}
24
+ {"assignment_id":"sumup","func_name":"sumup","reference_solution":"def sumup(n):\n\tif n < 2:\n\t\treturn n\n\tsum_to_n = sumup(n-1)\n\treturn n + sum_to_n","description":"Return the sum of all integers up to n.","test":"assert sumup(0)==0 and sumup(1)==1 and sumup(2)==3 and sumup(10)==55 and sumup(27)==378"}
 
 
data/dublin_metadata_train.jsonl CHANGED
@@ -1,30 +1,25 @@
1
- {"assignment_id":"reverse.py_ca277_reverse","func_name":"reverse","reference_solution":"def reverse(a):\n b=[]\n i=0\n while i < len(a):\n b.append(a[len(a)-1-i])\n i = i + 1\n return b","description":"Reverse a list of elements.","test":"assert reverse([])==[] and reverse([20, 10, 0, -10, -20])==[-20, -10, 0, 10, 20] and reverse(['toto', True, [10, 0, 9], 12.8, 6])==[6, 12.8, [10, 0, 9], True, 'toto']"}
2
- {"assignment_id":"func_selection_sort.py_ca116_selection_sort","func_name":"selection_sort","reference_solution":"def selection_sort(a):\n\ti=0\n\twhile i<len(a):\n\t\tp=i\n\t\tj=i+1\n\t\twhile j < len(a):\n\t\t\tif a[j] < a[p] :\n\t\t\t\tp=j\n\t\t\tj=j+1\n\t\ttmp=a[p]\n\t\ta[p]=a[i]\n\t\ta[i]=tmp\n\t\ti=i+1\n\treturn a\n\n","description":"Repeatedly move minimimum of remaining sublist to front.","test":"assert selection_sort([])==[] and selection_sort([0])==[0] and selection_sort([25204, -1, -18176])==[-18176, -1, 25204] and selection_sort([-18176, -1, 25204])==[-18176, -1, 25204]"}
3
- {"assignment_id":"func_reverse.py_ca116_reverse","func_name":"reverse","reference_solution":"def reverse(a):\n b=[]\n i=0\n while i < len(a):\n b.append(a[len(a)-1-i])\n i = i + 1\n return b","description":"Reverse a list of elements.","test":"assert reverse([])==[] and reverse([0])==[0] and reverse([-103, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, 1867157052])==[1867157052, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, -103] and reverse([-103, 113466788817036974729578468346735566318, 31758, 1867157052, 10933, -70, 1867157052])==[1867157052, -70, 10933, 1867157052, 31758, 113466788817036974729578468346735566318, -103] and reverse([1867157052, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, -103])==[-103, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, 1867157052] and reverse([1867157052, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, -103])==[-103, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, 1867157052] and reverse([-103, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, 1867157052])==[1867157052, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, -103] and reverse([[1]])==[[1]]"}
4
- {"assignment_id":"func_bsearch.py_ca116_bsearch","func_name":"bsearch","reference_solution":"def bsearch(a, q):\n low = 0\n high = len(a)\n while low < high:\n mid = (low + high) \/\/ 2\n if a[mid] < q:\n low = mid + 1\n else:\n high = mid\n return low","description":"Search for an element in an array using the binary search algorithm.","test":"assert bsearch([],12)==0 and bsearch([1, 2, 3, 4, 6, 7, 8],5)==4 and bsearch([1, 2, 3, 4, 6, 7, 8],1)==0 and bsearch([1, 2, 3, 4, 6, 7, 8],4)==3"}
5
- {"assignment_id":"swap_42.py_ca117_swap_keys_values","func_name":"swap_keys_values","reference_solution":"def swap_keys_values(d):\n return {v: k for (k, v) in list(d.items())}\n","description":"Swap keys with values.","test":"assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'}"}
6
- {"assignment_id":"swap_more_42.py_ca117_swap_unique_keys_values","func_name":"swap_unique_keys_values","reference_solution":"def swap_unique_keys_values(d):\n # Have to explicitly convert dict_view type to list type in Python 3\n return dict([(v, k) for (k, v) in list(d.items()) if list(d.values()).count(v) == 1])\n","description":"Swap keys with unique values.","test":"assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'}"}
7
- {"assignment_id":"circle_62.py_ca117_overlap","func_name":"overlap","reference_solution":"def overlap(x1=0, y1=0, r1=1, x2=0, y2=0, r2=1):\n d = ((x2-x1)**2 + (y2-y1)**2)**0.5\n if d < r1 + r2:\n return True\n return False\n\n","description":"Test if two circles overlap.","test":"assert overlap(0,0,0,0,0,0)==False and overlap(-10127,-4523146639991987157,4984975518095343106,16069,-6161206257421287809,-21999)==True and overlap(28812,-95,-14565,-14231,-57,-13105)==False and overlap(29825,-1453,8499,60,-25950,-863536228)==False and overlap(4254,-23892,-290,8971,1739,-4934)==False and overlap(-632291906,26448,10662,-106,-158122742,24689)==False"}
8
- {"assignment_id":"mutable_62.py_ca117_append2list","func_name":"append2list","reference_solution":"def append2list(l1, l2=None):\n if l2 == None:\n l2 = []\n for i in l1:\n l2.append(i)\n return l2\n\n","description":"Append l1 to l2. If l2 not supplied default to empty list.","test":"assert append2list([0, 0],[0])==[0, 0, 0] and append2list([0, 0, 0, 0, 0],[0, 0, 0])==[0, 0, 0, 0, 0, 0, 0, 0] and append2list([0, 0],[0, 0, 0])==[0, 0, 0, 0, 0] and append2list([],[])==[] and append2list([0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0, 0, 0])==[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]"}
9
- {"assignment_id":"funcs.py_ca278_merge_lists","func_name":"merge_lists","reference_solution":"def merge_lists(l1,l2):\n '''take two lists l1 and l2 and return a third list which contains \n every second element of l1 and l2'''\n l3 = []\n i = 0\n while i < len(l1):\n l3.append(l1[i])\n i += 2\n i = 0\n while i < len(l2):\n l3.append(l2[i])\n i += 2\n return l3\n\n","description":"Obtain every second element of l1 and l2.","test":"assert merge_lists([],[])==[] and merge_lists([],[1, 2, 3, 4])==[1, 3] and merge_lists([1, 2, 3, 4],[])==[1, 3] and merge_lists([10, 20, 45, 2, -10987, 89165],[9, 0, -6754, 5625264, 8765])==[10, 45, -10987, 9, -6754, 8765]"}
10
- {"assignment_id":"funcs.py_ca278_remove_zeros","func_name":"remove_zeros","reference_solution":"def remove_zeros(list):\n '''take a list of numbers and remove zeros from the list'''\n while 0 in list:\n list.remove(0)\n\n","description":"Remove zeros from list.","test":"assert remove_zeros([])==None and remove_zeros([])==None and remove_zeros([1, 2, 3, 4, -12, -2])==None and remove_zeros([1, 2, 3, 4, -12, -2])==None and remove_zeros([0, 0, 0, 0, 0])==None and remove_zeros([0, 0, 0, 0, 0])==None and remove_zeros([1, 0, 3, 2, 1, 9, 0, 0, 0])==None and remove_zeros([1, 0, 3, 2, 1, 9, 0, 0, 0])==None"}
11
- {"assignment_id":"funcs08.py_ca278_merge_lists","func_name":"merge_lists","reference_solution":"def merge_lists(l1,l2):\n '''take two lists l1 and l2 and return a third list which contains \n every second element of l1 and l2'''\n l3 = []\n i = 0\n while i < len(l1):\n l3.append(l1[i])\n i += 2\n i = 0\n while i < len(l2):\n l3.append(l2[i])\n i += 2\n return l3\n\n","description":"Obtain every second element of l1 and l2.","test":"assert merge_lists([],[])==[] and merge_lists([],[1, 2, 3, 4])==[1, 3] and merge_lists([1, 2, 3, 4],[])==[1, 3] and merge_lists([10, 20, 45, 2, -10987, 89165],[9, 0, -6754, 5625264, 8765])==[10, 45, -10987, 9, -6754, 8765]"}
12
- {"assignment_id":"funcs08.py_ca278_remove_zeros","func_name":"remove_zeros","reference_solution":"def remove_zeros(list):\n '''remove zeros from list'''\n while 0 in list:\n list.remove(0)\n\n","description":"Remove zeros from list.","test":"assert remove_zeros([])==None and remove_zeros([])==None and remove_zeros([1, 2, 3, 4, -12, -2])==None and remove_zeros([1, 2, 3, 4, -12, -2])==None and remove_zeros([0, 0, 0, 0, 0])==None and remove_zeros([0, 0, 0, 0, 0])==None and remove_zeros([1, 0, 3, 2, 1, 9, 0, 0, 0])==None and remove_zeros([1, 0, 3, 2, 1, 9, 0, 0, 0])==None"}
13
- {"assignment_id":"funcs08.py_ca278_search","func_name":"search","reference_solution":"def search(str,sub):\n '''returns the position of sub in str, -1 if it is not there'''\n i = 0\n while i < len(str):\n if sub == str[i]:\n return i\n i = i + 1\n return -1\n\n","description":"Return whether a letter is part of a string","test":"assert search('','0')==-1 and search('0','0')==0 and search('ERFE0Rfsef','0')==4 and search('ERFERfsef0','0')==9 and search('','a')==-1 and search('cbzeycuzbvyzuvb','a')==-1 and search('cbsducsvdbcyts','c')==0 and search('dbzeducvbzy','y')==10 and search('xqvsgxcutvy','u')==7"}
14
- {"assignment_id":"funcs08.py_ca278_fibonacci","func_name":"fibonacci","reference_solution":"def fibonacci(n):\n '''returns the value of the fibonnaci series at position n'''\n if n == 0:\n return 1\n elif n == 1:\n return 1\n else:\n fibN_2 = 1\n fibN_1 = 1\n i = 2\n while i <=n:\n fibN = fibN_2 + fibN_1\n fibN_2 = fibN_1\n fibN_1 = fibN\n i = i + 1\n return fibN\n\n","description":"Return the value of the fibonacci series at position n.","test":"assert fibonacci(0)==1 and fibonacci(1)==1 and fibonacci(2)==2 and fibonacci(10)==89 and fibonacci(23)==46368"}
15
- {"assignment_id":"iterative08.py_ca278_search","func_name":"search","reference_solution":"def search(str,letter):\n '''returns True if letter is in str, False if it is not there'''\n i = 0\n while i < len(str):\n if letter == str[i]:\n return True\n i = i + 1\n return False\n\n","description":"Return whether a letter is part of a string","test":"assert search('','0')==False and search('0','0')==True and search('ERFE0Rfsef','0')==True and search('ERFERfsef0','0')==True and search('','a')==False and search('cbzeycuzbvyzuvb','a')==False and search('cbsducsvdbcyts','c')==True and search('dbzeducvbzy','y')==True and search('xqvsgxcutvy','u')==True"}
16
- {"assignment_id":"iterative08.py_ca278_index","func_name":"index","reference_solution":"def index(str,letter):\n '''returns the position of letter in str, -1 if it is not there'''\n i = 0\n while i < len(str):\n if letter == str[i]:\n return i\n i = i + 1\n return -1\n\n\n","description":"Returns the position of letter in str, -1 if it is not there.","test":"assert index('','0')==-1 and index('0','0')==0 and index('9dK=1%s)a>PI5FmV\/dq,-=]N2MmOkB .hRL_P2','=')==3"}
17
- {"assignment_id":"iterative08.py_ca278_fibonacci","func_name":"fibonacci","reference_solution":"def fibonacci(n):\n '''returns the value of the fibonnaci series at position n'''\n if n == 0 or n == 1:\n return 1\n else:\n fibN_2 = 1\n fibN_1 = 1\n i = 2\n while i <=n:\n fibN = fibN_2 + fibN_1\n fibN_2 = fibN_1\n fibN_1 = fibN\n i = i + 1\n return fibN\n\n","description":"Return the value of the fibonacci series at position n.","test":"assert fibonacci(0)==1 and fibonacci(1)==1 and fibonacci(2)==2 and fibonacci(10)==89 and fibonacci(23)==46368"}
18
- {"assignment_id":"recursive08.py_ca278_search","func_name":"search","reference_solution":"def search(str,letter):\n '''returns True if letter is in str, False otherwise'''\n if str == \"\":\n return False\n elif str[0] == letter:\n return True\n else:\n #keep looking\n return search(str[1:],letter)\n \n\n","description":"Return whether a letter is part of a string","test":"assert search('','0')==False and search('0','0')==True and search('ERFE0Rfsef','0')==True and search('ERFERfsef0','0')==True and search('','a')==False and search('cbzeycuzbvyzuvb','a')==False and search('cbsducsvdbcyts','c')==True and search('dbzeducvbzy','y')==True and search('xqvsgxcutvy','u')==True"}
19
- {"assignment_id":"recursive08.py_ca278_index","func_name":"index","reference_solution":"def index(str,letter,pos):\n '''returns the position of letter in str, -1 if it is not there'''\n if pos == len(str):\n return -1\n elif str[pos] == letter:\n return pos\n else:\n return index(str,letter,pos+1)\n\n\n","description":"Return the position of letter in str, -1 if it is not there.","test":"assert index('','0',0)==-1 and index('dc8','s',0)==-1"}
20
- {"assignment_id":"recursive08.py_ca278_fibonacci","func_name":"fibonacci","reference_solution":"def fibonacci(n):\n '''returns the value of the fibonacci series at position n'''\n if n == 0:\n return 0\n elif n == 1:\n return 1\n else:\n return fibonacci(n-1) + fibonacci(n-2)\n\n","description":"Return the value of the fibonacci series at position n.","test":"assert fibonacci(0)==0 and fibonacci(1)==1 and fibonacci(2)==1 and fibonacci(10)==55 and fibonacci(23)==28657"}
21
- {"assignment_id":"count_102.py_ca117_count_letters","func_name":"count_letters","reference_solution":"def count_letters(s):\n if not s:\n return 0\n return 1 + count_letters(s[1:])\n","description":"Return the number of lettres in a string.","test":"assert count_letters('')==0 and count_letters('0')==1 and count_letters('##')==2 and count_letters('t')==1 and count_letters('fqfseqfseqsse')==13"}
22
- {"assignment_id":"fibonacci_102.py_ca117_fibonacci","func_name":"fibonacci","reference_solution":"def fibonacci(n):\n if n == 0:\n return 1\n if n == 1:\n return 1\n return fibonacci(n-1) + fibonacci(n-2)\n","description":"Return the value of the fibonacci series at position n.","test":"assert fibonacci(0)==1 and fibonacci(1)==1 and fibonacci(2)==2 and fibonacci(10)==89 and fibonacci(23)==46368"}
23
- {"assignment_id":"maximum_102.py_ca117_maximum","func_name":"maximum","reference_solution":"def maximum(l):\n if len(l) == 1:\n return l[0]\n tail_max = maximum(l[1:])\n return l[0] if l[0] > tail_max else tail_max\n # Could do this but ought not use max I suppose...\n # return max(l[0], maximum(l[1:]))\n","description":"Return the maximum element in a list of numbers.","test":"assert maximum([0])==0 and maximum([67, 1, 2, -2, 0])==67 and maximum([0, -2, 2, 1, 67])==67 and maximum([-10, -23, -45, -9, -45617])==-9"}
24
- {"assignment_id":"minimum_102.py_ca117_minimum","func_name":"minimum","reference_solution":"def minimum(l):\n if len(l) == 1:\n return l[0]\n tail_min = minimum(l[1:])\n return l[0] if l[0] < tail_min else tail_min\n # Could do this but ought not use min I suppose...\n # return min(l[0], rmin(l[1:]))\n","description":"Return the minimum element in a list of numbers.","test":"assert minimum([0])==0 and minimum([2, 10, 23, 9, 187])==2 and minimum([-2, -26, 7, -123, -1236521])==-1236521 and minimum([3896, 3673, 45, 16715, 23673])==45"}
25
- {"assignment_id":"selectionsort_102.py_ca117_selectionsort","func_name":"selectionsort","reference_solution":"def selectionsort(A):\n\n i = 0\n while i < len(A):\n min_index = i\n j = i+1\n while j < len(A):\n if A[j] < A[min_index]:\n min_index = j\n j += 1\n A[i], A[min_index] = A[min_index], A[i]\n i += 1\n\n# repeatedly insert into sorted array\n","description":"Repeatedly move minimimum of remaining sublist to front.","test":"assert selectionsort([])==None and selectionsort([])==None and selectionsort([0])==None and selectionsort([0])==None"}
26
- {"assignment_id":"quicksort_102.py_ca117_quicksort","func_name":"quicksort","reference_solution":"def partition(A, p, r):\n q = j = p\n while j < r:\n if A[j] <= A[r]:\n A[q], A[j] = A[j], A[q]\n q = q + 1\n j = j + 1\n A[q], A[r] = A[r], A[q]\n return q\n\n \ndef quicksort(A, p, r):\n \n def partition(A, p, r):\n q = j = p\n while j < r:\n if A[j] <= A[r]:\n A[q], A[j] = A[j], A[q]\n q = q + 1\n j = j + 1\n A[q], A[r] = A[r], A[q]\n return q\n\n if r <= p:\n return\n q = partition(A, p, r)\n quicksort(A, p, q-1)\n quicksort(A, q + 1, r)","description":"Recursively partition list until sorted.","test":"assert quicksort([],0,0)==None and quicksort([],0,0)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None"}
27
- {"assignment_id":"reverse_102.py_ca117_reverse_list","func_name":"reverse_list","reference_solution":"def reverse_list(l):\n if l == []:\n return []\n return reverse_list(l[1:]) + [l[0]]\n # temp = reverse(l[1:])\n # temp.append(l[0])\n # return temp\n # note we cannot use return reverse(l[1:]).append(l[0]) because append()\n # does not return anything\n","description":"Reverse a list of elements.","test":"assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]"}
28
- {"assignment_id":"selection_sort.py_ca277_sort","func_name":"sort","reference_solution":"def swap(a, i, j):\n tmp = a[i]\n a[i] = a[j]\n a[j] = tmp\n\n\ndef find_position_of_smallest(a, i):\n p = i \n while i < len(a):\n if a[i] < a[p]:\n p = i\n i = i + 1\n return p\t\n \n\ndef sort(a):\n i = 0\n while i < len(a):\n p = find_position_of_smallest(a,i) \n swap(a, i, p)\n i = i + 1\n","description":"Repeatedly move minimimum of remaining sublist to front.","test":"assert sort([0])==None and sort([0])==None and sort([])==None and sort([])==None and sort([' '])==None and sort([' '])==None and sort([70, 339305549])==None and sort([70, 339305549])==None"}
29
- {"assignment_id":"sets.py_ca277_union","func_name":"union","reference_solution":"def union(a, b):\n\tc=[]\n\ti = 0\n\twhile i < len(a):\n\t\tif a[i] not in c:\n\t\t\tc.append(a[i])\n\t\ti = i + 1\n\n\tp = 0\n\twhile p < len(b):\n\t\tif b[p] not in c:\n\t\t\tc.append(b[p])\n\t\tp = p + 1\n\n\treturn c\n\n","description":"Merge two lists into a single one.","test":"assert union([],[])==[] and union([25785],[25785])==[25785] and union([-90, 21135, 29310, -8059, 7114, -90, -5808, 1333, -18691, 7, -19450, 67745575129021321678860432754396203799, -9288, -161403197171354040520992237328119268342, 49, 120528818203287557, 133011337445419463191476642795673848676, 11952, 11996],[5, -9316, 7379237229304681733])==[-90, 21135, 29310, -8059, 7114, -5808, 1333, -18691, 7, -19450, 67745575129021321678860432754396203799, -9288, -161403197171354040520992237328119268342, 49, 120528818203287557, 133011337445419463191476642795673848676, 11952, 11996, 5, -9316, 7379237229304681733]"}
30
- {"assignment_id":"sets.py_ca277_intersection","func_name":"intersection","reference_solution":"def intersection(a, b):\n\td=[]\n\ti = 0\n\twhile i < len(a):\n\t\tif a[i] in b and a[i] not in d:\n\t\t\td.append(a[i])\n\t\ti = i + 1\n\n\treturn d","description":"Return the elements which are in both lists.","test":"assert intersection([],[])==[] and intersection([20052, 20052, -9991],[102, 20052, -9991])==[20052, -9991] and intersection([38908273694008580353068229963801163341, 59, 38908273694008580353068229963801163341, -38, 28239, -2723, 24559, -5794],[38908273694008580353068229963801163341, 59, 38908273694008580353068229963801163341, -38, 28239, -2723, 24559, -5794])==[38908273694008580353068229963801163341, 59, -38, 28239, -2723, 24559, -5794]"}
 
1
+ {"assignment_id":"reverse_iter","func_name":"reverse","reference_solution":"def reverse(a):\n b=[]\n i=0\n while i < len(a):\n b.append(a[len(a)-1-i])\n i = i + 1\n return b","description":"Iteratively reverse a list of elements.","test":"assert reverse([])==[] and reverse([20, 10, 0, -10, -20])==[-20, -10, 0, 10, 20] and reverse(['toto', True, [10, 0, 9], 12.8, 6])==[6, 12.8, [10, 0, 9], True, 'toto']"}
2
+ {"assignment_id":"selection_sort","func_name":"selection_sort","reference_solution":"def selection_sort(a):\n\ti=0\n\twhile i<len(a):\n\t\tp=i\n\t\tj=i+1\n\t\twhile j < len(a):\n\t\t\tif a[j] < a[p] :\n\t\t\t\tp=j\n\t\t\tj=j+1\n\t\ttmp=a[p]\n\t\ta[p]=a[i]\n\t\ta[i]=tmp\n\t\ti=i+1\n\treturn a\n\n","description":"Sort a list by repeatedly move minimimum of remaining sublist to front.","test":"assert selection_sort([])==[] and selection_sort([0])==[0] and selection_sort([25204, -1, -18176])==[-18176, -1, 25204] and selection_sort([-18176, -1, 25204])==[-18176, -1, 25204]"}
3
+ {"assignment_id":"reverse_by_swap","func_name":"reverse","reference_solution":"def reverse(a):\n b=[]\n i=0\n while i < len(a):\n b.append(a[len(a)-1-i])\n i = i + 1\n return b","description":"Reverse a list of elements by swapping its elements.","test":"assert reverse([])==[] and reverse([0])==[0] and reverse([-103, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, 1867157052])==[1867157052, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, -103] and reverse([-103, 113466788817036974729578468346735566318, 31758, 1867157052, 10933, -70, 1867157052])==[1867157052, -70, 10933, 1867157052, 31758, 113466788817036974729578468346735566318, -103] and reverse([1867157052, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, -103])==[-103, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, 1867157052] and reverse([1867157052, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, -103])==[-103, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, 1867157052] and reverse([-103, 113466788817036974729578468346735566318, 31758, -70, 10933, 1867157052, 1867157052])==[1867157052, 1867157052, 10933, -70, 31758, 113466788817036974729578468346735566318, -103] and reverse([[1]])==[[1]]"}
4
+ {"assignment_id":"bsearch","func_name":"bsearch","reference_solution":"def bsearch(a, q):\n low = 0\n high = len(a)\n while low < high:\n mid = (low + high) \/\/ 2\n if a[mid] < q:\n low = mid + 1\n else:\n high = mid\n return low","description":"Search for element q in the sorted array a.","test":"assert bsearch([],12)==0 and bsearch([1, 2, 3, 4, 6, 7, 8],5)==4 and bsearch([1, 2, 3, 4, 6, 7, 8],1)==0 and bsearch([1, 2, 3, 4, 6, 7, 8],4)==3"}
5
+ {"assignment_id":"count_letters","func_name":"count_letters","reference_solution":"def count_letters(s):\n if not s:\n return 0\n return 1 + count_letters(s[1:])\n","description":"Return the number of lettres in a string.","test":"assert count_letters('')==0 and count_letters('0')==1 and count_letters('##')==2 and count_letters('t')==1 and count_letters('fqfseqfseqsse')==13"}
6
+ {"assignment_id":"maximum","func_name":"maximum","reference_solution":"def maximum(l):\n if len(l) == 1:\n return l[0]\n tail_max = maximum(l[1:])\n return l[0] if l[0] > tail_max else tail_max\n # Could do this but ought not use max I suppose...\n # return max(l[0], maximum(l[1:]))\n","description":"Return the maximum element in a list of numbers.","test":"assert maximum([0])==0 and maximum([67, 1, 2, -2, 0])==67 and maximum([0, -2, 2, 1, 67])==67 and maximum([-10, -23, -45, -9, -45617])==-9"}
7
+ {"assignment_id":"minimum","func_name":"minimum","reference_solution":"def minimum(l):\n if len(l) == 1:\n return l[0]\n tail_min = minimum(l[1:])\n return l[0] if l[0] < tail_min else tail_min\n # Could do this but ought not use min I suppose...\n # return min(l[0], rmin(l[1:]))\n","description":"Return the minimum element in a list of numbers.","test":"assert minimum([0])==0 and minimum([2, 10, 23, 9, 187])==2 and minimum([-2, -26, 7, -123, -1236521])==-1236521 and minimum([3896, 3673, 45, 16715, 23673])==45"}
8
+ {"assignment_id":"selectionsort","func_name":"selectionsort","reference_solution":"def selectionsort(A):\n\n i = 0\n while i < len(A):\n min_index = i\n j = i+1\n while j < len(A):\n if A[j] < A[min_index]:\n min_index = j\n j += 1\n A[i], A[min_index] = A[min_index], A[i]\n i += 1\n\n# repeatedly insert into sorted array\n","description":"Sort a list by repeatedly move minimimum of remaining sublist to front.","test":"assert selectionsort([])==None and selectionsort([])==None and selectionsort([0])==None and selectionsort([0])==None"}
9
+ {"assignment_id":"quicksort","func_name":"quicksort","reference_solution":"def partition(A, p, r):\n q = j = p\n while j < r:\n if A[j] <= A[r]:\n A[q], A[j] = A[j], A[q]\n q = q + 1\n j = j + 1\n A[q], A[r] = A[r], A[q]\n return q\n\n \ndef quicksort(A, p, r):\n \n def partition(A, p, r):\n q = j = p\n while j < r:\n if A[j] <= A[r]:\n A[q], A[j] = A[j], A[q]\n q = q + 1\n j = j + 1\n A[q], A[r] = A[r], A[q]\n return q\n\n if r <= p:\n return\n q = partition(A, p, r)\n quicksort(A, p, q-1)\n quicksort(A, q + 1, r)","description":"Sort a list by recursively partitionioning list until sorted.","test":"assert quicksort([],0,0)==None and quicksort([],0,0)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 4, 3, 2, 1],0,4)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5, 5, 5, 5],0,3)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None and quicksort([5675, 564, 987, 154132, 8976, 0, -16221, 87526, 9826732986],0,8)==None"}
10
+ {"assignment_id":"reverse_recur","func_name":"reverse_list","reference_solution":"def reverse_list(l):\n if l == []:\n return []\n return reverse_list(l[1:]) + [l[0]]\n # temp = reverse(l[1:])\n # temp.append(l[0])\n # return temp\n # note we cannot use return reverse(l[1:]).append(l[0]) because append()\n # does not return anything\n","description":"Recursively reverse a list of elements.","test":"assert reverse_list([])==[] and reverse_list([0])==[0] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457, 85, -74, -10050, 787, -3])==[-3, 787, -10050, -74, 85, -109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650] and reverse_list([0, 0])==[0, 0] and reverse_list([85, -74, -10050, 787, 9650, 12103, -1947378123, -109345868112896702250879906349988323457, -3])==[-3, -109345868112896702250879906349988323457, -1947378123, 12103, 9650, 787, -10050, -74, 85] and reverse_list([85, -74, -10050, 787, -3, 9650, 12103, -1947378123, -109345868112896702250879906349988323457])==[-109345868112896702250879906349988323457, -1947378123, 12103, 9650, -3, 787, -10050, -74, 85]"}
11
+ {"assignment_id":"sort","func_name":"sort","reference_solution":"def swap(a, i, j):\n tmp = a[i]\n a[i] = a[j]\n a[j] = tmp\n\n\ndef find_position_of_smallest(a, i):\n p = i \n while i < len(a):\n if a[i] < a[p]:\n p = i\n i = i + 1\n return p\t\n \n\ndef sort(a):\n i = 0\n while i < len(a):\n p = find_position_of_smallest(a,i) \n swap(a, i, p)\n i = i + 1\n","description":"Sort a list by repeatedly moving the minimimum of the remaining sublist to the front.","test":"assert sort([0])==None and sort([0])==None and sort([])==None and sort([])==None and sort([' '])==None and sort([' '])==None and sort([70, 339305549])==None and sort([70, 339305549])==None"}
12
+ {"assignment_id":"union","func_name":"union","reference_solution":"def union(a, b):\n\tc=[]\n\ti = 0\n\twhile i < len(a):\n\t\tif a[i] not in c:\n\t\t\tc.append(a[i])\n\t\ti = i + 1\n\n\tp = 0\n\twhile p < len(b):\n\t\tif b[p] not in c:\n\t\t\tc.append(b[p])\n\t\tp = p + 1\n\n\treturn c\n\n","description":"Merge two lists into a single one.","test":"assert union([],[])==[] and union([25785],[25785])==[25785] and union([-90, 21135, 29310, -8059, 7114, -90, -5808, 1333, -18691, 7, -19450, 67745575129021321678860432754396203799, -9288, -161403197171354040520992237328119268342, 49, 120528818203287557, 133011337445419463191476642795673848676, 11952, 11996],[5, -9316, 7379237229304681733])==[-90, 21135, 29310, -8059, 7114, -5808, 1333, -18691, 7, -19450, 67745575129021321678860432754396203799, -9288, -161403197171354040520992237328119268342, 49, 120528818203287557, 133011337445419463191476642795673848676, 11952, 11996, 5, -9316, 7379237229304681733]"}
13
+ {"assignment_id":"intersection","func_name":"intersection","reference_solution":"def intersection(a, b):\n\td=[]\n\ti = 0\n\twhile i < len(a):\n\t\tif a[i] in b and a[i] not in d:\n\t\t\td.append(a[i])\n\t\ti = i + 1\n\n\treturn d","description":"Return the intersection between two lists.","test":"assert intersection([],[])==[] and intersection([20052, 20052, -9991],[102, 20052, -9991])==[20052, -9991] and intersection([38908273694008580353068229963801163341, 59, 38908273694008580353068229963801163341, -38, 28239, -2723, 24559, -5794],[38908273694008580353068229963801163341, 59, 38908273694008580353068229963801163341, -38, 28239, -2723, 24559, -5794])==[38908273694008580353068229963801163341, 59, -38, 28239, -2723, 24559, -5794]"}
14
+ {"assignment_id":"swap_keys_values","func_name":"swap_keys_values","reference_solution":"def swap_keys_values(d):\n return dict([(v, k) for (k, v) in list(d.items())])\n","description":"Swap the keys of a dictionary with its values.","test":"assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'}"}
15
+ {"assignment_id":"swap_unique_keys_values","func_name":"swap_unique_keys_values","reference_solution":"def swap_unique_keys_values(d):\n # Have to explicitly convert dict_view type to list type in Python 3\n return dict([(v, k) for (k, v) in list(d.items()) if list(d.values()).count(v) == 1])\n","description":"Swap the keys of a dictionary with its unique values.","test":"assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'}"}
16
+ {"assignment_id":"merge_lists","func_name":"merge_lists","reference_solution":"def merge_lists(l1,l2):\n '''take two lists l1 and l2 and return a third list which contains \n every second element of l1 and l2'''\n l3 = []\n i = 0\n while i < len(l1):\n l3.append(l1[i])\n i += 2\n i = 0\n while i < len(l2):\n l3.append(l2[i])\n i += 2\n return l3\n\n","description":"Take two lists l1 and l2 and return a third list which contains every second element of l1 and l2.","test":"assert merge_lists([],[])==[] and merge_lists([],[1, 2, 3, 4])==[1, 3] and merge_lists([1, 2, 3, 4],[])==[1, 3] and merge_lists([10, 20, 45, 2, -10987, 89165],[9, 0, -6754, 5625264, 8765])==[10, 45, -10987, 9, -6754, 8765]"}
17
+ {"assignment_id":"remove_zeros","func_name":"remove_zeros","reference_solution":"def remove_zeros(list):\n '''take a list of numbers and remove zeros from the list'''\n while 0 in list:\n list.remove(0)\n\n","description":"Take a list of numbers and removes the zeros from it.","test":"assert remove_zeros([])==None and remove_zeros([])==None and remove_zeros([5202, -24344, -6528])==None and remove_zeros([5202, -24344, -6528])==None"}
18
+ {"assignment_id":"overlap","func_name":"overlap","reference_solution":"def overlap(x1=0, y1=0, r1=1, x2=0, y2=0, r2=1):\n d = ((x2-x1)**2 + (y2-y1)**2)**0.5\n if d < r1 + r2:\n return True\n return False\n\n","description":"Test if two circles overlap.","test":"assert overlap(12,-6058,21436,-3483096651887624530,24,31017)==False and overlap(-30592,-26624,-11905,1,2,30134)==False and overlap(0,0,0,0,0,0)==False and overlap(5128,-8635,-28938,25,-31295,-21637807133189218411179185993653430151)==False and overlap(-16348,-2218,2871,-15155,-83,24475)==True and overlap(4807,1216206119,8753907074291481720,-19844,-26061,-15639)==True and overlap(1348593950,19232,-10923,20,2259187900768772679,-5343103208648864320)==False and overlap(8410739119977124611,9995,83,8410739119977124611,19348,21604)==True"}
19
+ {"assignment_id":"append2list","func_name":"append2list","reference_solution":"def append2list(l1, l2=None):\n if l2 == None:\n l2 = []\n for i in l1:\n l2.append(i)\n return l2\n\n","description":"Appends elements of a list l1 at the end of the list l2. If l2 not supplied default to empty list.","test":"assert append2list([-12248, -4743, -25, -6030600119498841921, -8866],[-16276, 117, -12248, -4743, -25, -6030600119498841921, -8866])==[-16276, 117, -12248, -4743, -25, -6030600119498841921, -8866, -12248, -4743, -25, -6030600119498841921, -8866] and append2list([-12248, -4743, -25, -6030600119498841921, -8866],[-16276, 117, -12248, -4743, -25, -6030600119498841921, -8866, -12248, -4743, -25, -6030600119498841921, -8866])==[-16276, 117, -12248, -4743, -25, -6030600119498841921, -8866, -12248, -4743, -25, -6030600119498841921, -8866, -12248, -4743, -25, -6030600119498841921, -8866] and append2list([-12248, -4743, -25, -6030600119498841921, -8866, -16276, 117, -12248, -4743, -25, -6030600119498841921, -8866, -12248, -4743, -25, -6030600119498841921, -8866],[-16276, 117, -12248, -4743, -25, -6030600119498841921, -8866, -12248, -4743, -25, -6030600119498841921, -8866])==[-16276, 117, -12248, -4743, -25, -6030600119498841921, -8866, -12248, -4743, -25, -6030600119498841921, -8866, -12248, -4743, -25, -6030600119498841921, -8866, -16276, 117, -12248, -4743, -25, -6030600119498841921, -8866, -12248, -4743, -25, -6030600119498841921, -8866] and append2list([-21267],[-21267, -21267])==[-21267, -21267, -21267]"}
20
+ {"assignment_id":"search_iter","func_name":"search","reference_solution":"def search(str,letter):\n '''returns True if letter is in str, False if it is not there'''\n i = 0\n while i < len(str):\n if letter == str[i]:\n return True\n i = i + 1\n return False\n\n","description":"Iteratively search for a letter in a string","test":"assert search('','0')==False and search('0','0')==True and search('ERFE0Rfsef','0')==True and search('ERFERfsef0','0')==True and search('','a')==False and search('cbzeycuzbvyzuvb','a')==False and search('cbsducsvdbcyts','c')==True and search('dbzeducvbzy','y')==True and search('xqvsgxcutvy','u')==True"}
21
+ {"assignment_id":"index_iter","func_name":"index","reference_solution":"def index(str,letter):\n '''returns the position of letter in str, -1 if it is not there'''\n i = 0\n while i < len(str):\n if letter == str[i]:\n return i\n i = i + 1\n return -1\n\n\n","description":"Iteratively search for the position of letter in str, return -1 if it is not there.","test":"assert index('','0')==-1 and index('0','0')==0 and index('11','1')==0"}
22
+ {"assignment_id":"fibonacci_iter","func_name":"fibonacci","reference_solution":"def fibonacci(n):\n '''returns the value of the fibonacci series at position n'''\n if n == 0:\n return 0\n if n == 1:\n return 1\n else:\n fibN_2 = 0\n fibN_1 = 1\n i = 2\n while i <=n:\n fibN = fibN_2 + fibN_1\n fibN_2 = fibN_1\n fibN_1 = fibN\n i = i + 1\n return fibN\n\n","description":"Iteratively compute the value of the fibonacci series at position n.","test":"assert fibonacci(0)==0 and fibonacci(1)==1 and fibonacci(2)==1 and fibonacci(10)==55 and fibonacci(23)==28657"}
23
+ {"assignment_id":"search_recur","func_name":"search","reference_solution":"def search(str,letter):\n '''returns True if letter is in str, False otherwise'''\n if str == \"\":\n return False\n elif str[0] == letter:\n return True\n else:\n #keep looking\n return search(str[1:],letter)\n \n\n","description":"Recursively search for a letter in a string","test":"assert search('','0')==False and search('0','0')==True and search('ERFE0Rfsef','0')==True and search('ERFERfsef0','0')==True and search('','a')==False and search('cbzeycuzbvyzuvb','a')==False and search('cbsducsvdbcyts','c')==True and search('dbzeducvbzy','y')==True and search('xqvsgxcutvy','u')==True"}
24
+ {"assignment_id":"index_recur","func_name":"index","reference_solution":"def index(str,letter,pos):\n '''returns the position of letter in str, -1 if it is not there'''\n if pos == len(str):\n return -1\n elif str[pos] == letter:\n return pos\n else:\n return index(str,letter,pos+1)\n\n\n","description":"Recursively search for the position of letter in str, return -1 if it is not there.","test":"assert index('','0',0)==-1 and index('0','0',0)==0 and index('a','8',0)==-1 and index('tV2','2',0)==2"}
25
+ {"assignment_id":"fibonacci_recur","func_name":"fibonacci","reference_solution":"def fibonacci(n):\n '''returns the value of the fibonacci series at position n'''\n if n == 0:\n return 0\n elif n == 1:\n return 1\n else:\n return fibonacci(n-1) + fibonacci(n-2)\n\n","description":"Recursively compute the value of the fibonacci series at position n.","test":"assert fibonacci(0)==0 and fibonacci(1)==1 and fibonacci(2)==1 and fibonacci(10)==55 and fibonacci(23)==28657"}