Adding metadata information and descriptions
Browse files- README.md +42 -7
- data/dublin_metadata_test.jsonl +26 -0
- data/dublin_metadata_train.jsonl +30 -0
- data/singapore_metadata_train.jsonl +5 -0
- intro_prog.py +110 -21
README.md
CHANGED
@@ -63,19 +63,15 @@ dataset_info:
|
|
63 |
dtype: string
|
64 |
- name: annotation
|
65 |
dtype: string
|
66 |
-
- name: user
|
67 |
-
dtype: string
|
68 |
-
- name: academic_year
|
69 |
-
dtype: int32
|
70 |
splits:
|
71 |
- name: train
|
72 |
-
num_bytes:
|
73 |
num_examples: 307
|
74 |
- name: test
|
75 |
-
num_bytes:
|
76 |
num_examples: 1698
|
77 |
download_size: 2137031
|
78 |
-
dataset_size:
|
79 |
- config_name: singapore_repair
|
80 |
features:
|
81 |
- name: submission_id
|
@@ -98,4 +94,43 @@ dataset_info:
|
|
98 |
num_examples: 18
|
99 |
download_size: 21737
|
100 |
dataset_size: 18979
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
---
|
|
|
63 |
dtype: string
|
64 |
- name: annotation
|
65 |
dtype: string
|
|
|
|
|
|
|
|
|
66 |
splits:
|
67 |
- name: train
|
68 |
+
num_bytes: 221120
|
69 |
num_examples: 307
|
70 |
- name: test
|
71 |
+
num_bytes: 1404632
|
72 |
num_examples: 1698
|
73 |
download_size: 2137031
|
74 |
+
dataset_size: 1625752
|
75 |
- config_name: singapore_repair
|
76 |
features:
|
77 |
- name: submission_id
|
|
|
94 |
num_examples: 18
|
95 |
download_size: 21737
|
96 |
dataset_size: 18979
|
97 |
+
- config_name: dublin_metadata
|
98 |
+
features:
|
99 |
+
- name: assignment_id
|
100 |
+
dtype: string
|
101 |
+
- name: func_name
|
102 |
+
dtype: string
|
103 |
+
- name: reference_solution
|
104 |
+
dtype: string
|
105 |
+
- name: description
|
106 |
+
dtype: string
|
107 |
+
- name: test
|
108 |
+
dtype: string
|
109 |
+
splits:
|
110 |
+
- name: train
|
111 |
+
num_bytes: 17562
|
112 |
+
num_examples: 30
|
113 |
+
- name: test
|
114 |
+
num_bytes: 15342
|
115 |
+
num_examples: 26
|
116 |
+
download_size: 37317
|
117 |
+
dataset_size: 32904
|
118 |
+
- config_name: singapore_metadata
|
119 |
+
features:
|
120 |
+
- name: assignment_id
|
121 |
+
dtype: string
|
122 |
+
- name: func_name
|
123 |
+
dtype: string
|
124 |
+
- name: reference_solution
|
125 |
+
dtype: string
|
126 |
+
- name: description
|
127 |
+
dtype: string
|
128 |
+
- name: test
|
129 |
+
dtype: string
|
130 |
+
splits:
|
131 |
+
- name: train
|
132 |
+
num_bytes: 5577
|
133 |
+
num_examples: 5
|
134 |
+
download_size: 6139
|
135 |
+
dataset_size: 5577
|
136 |
---
|
data/dublin_metadata_test.jsonl
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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"}
|
data/dublin_metadata_train.jsonl
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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]"}
|
data/singapore_metadata_train.jsonl
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{"reference_solution":"def search(x, seq):\n for i in range(len(seq)):\n if x <= seq[i]:\n return i\n return len(seq)","assignment_id":1,"func_name":"search","test":"assert search(42, (-5, 1, 3, 5, 7, 10))==6 and search(42, [1, 5, 10])==3 and search(5, (1, 5, 10))==1 and search(7, [1, 5, 10])==2 and search(3, (1, 5, 10))==1 and search(-5, (1, 5, 10))==0 and search(10, (-5, -1, 3, 5, 7, 10))==5 and search(-100, (-5, -1, 3, 5, 7, 10))==0 and search(0, (-5, -1, 3, 5, 7, 10))==2 and search(100, [])==0 and search(-100, ())==0","description":"Task: Sequential Search"}
|
2 |
+
{"reference_solution":"def unique_day(day, possible_birthdays):\n count = 0\n for birthday in possible_birthdays:\n if birthday[1] == day:\n count += 1\n return count == 1\n\ndef unique_month(month, possible_birthdays):\n count = 0\n for birthday in possible_birthdays:\n if birthday[0] == month:\n count += 1\n return count == 1\n\ndef contains_unique_day(month, possible_birthdays):\n for birthday in possible_birthdays:\n if birthday[0] == month and unique_day(birthday[1], possible_birthdays):\n return True\n return False\n","assignment_id":2,"func_name":"unique_day-unique_month-contains_unique_day","test":"\n\ntuple_of_possible_birthdays = (('May', '15'),\n ('May', '16'),\n ('May', '19'),\n ('June', '17'),\n ('June', '18'),\n ('July', '14'),\n ('July', '16'),\n ('August', '14'),\n ('August', '15'),\n ('August', '17'))\n\nassert unique_day(\"1\", ((\"January\",\"1\"),(\"February\",\"1\")))==False and unique_month(\"January\", ((\"January\",\"1\"),(\"January\",\"2\")))==False and unique_month(\"January\", ((\"January\",\"1\"),(\"February\",\"1\")))==True and contains_unique_day(\"January\", ((\"January\",\"1\"),(\"January\",\"2\")))==True and contains_unique_day(\"January\", ((\"January\",\"1\"),(\"February\",\"1\")))==False and contains_unique_day(\"February\", ((\"January\",\"10\"),(\"February\",\"1\"),(\"February\",\"10\")))==True and unique_day(\"3\", ((\"January\",\"1\"),(\"January\",\"2\")))==False and unique_month(\"March\", ((\"January\",\"1\"),(\"February\",\"1\")))==False and unique_day(\"1\", ((\"January\",\"1\"),(\"January\",\"2\")))==True and unique_day(\"16\", tuple_of_possible_birthdays)==False and unique_day(\"17\", tuple_of_possible_birthdays)==False and unique_day(\"18\", tuple_of_possible_birthdays)==True and unique_day(\"19\", tuple_of_possible_birthdays)==True and unique_month(\"May\", tuple_of_possible_birthdays)==False and unique_month(\"June\", tuple_of_possible_birthdays)==False and contains_unique_day(\"June\", tuple_of_possible_birthdays)==True and contains_unique_day(\"July\", tuple_of_possible_birthdays)==False","description":"Task: Unique dates and months\n\n\nImplement unique_day, unique_month and contains_unique_day."}
|
3 |
+
{"reference_solution":"def remove_extras(lst):\n newlist = []\n for i in lst:\n if i not in newlist:\n newlist.append(i)\n return newlist\n","assignment_id":3,"func_name":"remove_extras","test":"from collections import OrderedDict\nassert remove_extras([1, 1, 1, 2, 3])==[1, 2, 3] and remove_extras([1, 5, 1, 1, 3, 2])==[1, 5, 3, 2] and remove_extras([])==[] and remove_extras([3, 4, 5, 1, 3])==[3, 4, 5, 1] and remove_extras([3, 4, 5, 1, 3])==[3, 4, 5, 1] and remove_extras([3, 4, 5, 1, 3])==[3, 4, 5, 1]","description":"Task: Duplicate elimination\n\n\nWrite a function remove_extras(lst) that takes in a list and returns a new list with\nall repeated occurrences of any element removed. For example, remove_extras([5,\n2, 1, 2, 3]) returns the list [5, 2, 1, 3]."}
|
4 |
+
{"reference_solution":"def sort_age(lst):\n for i in range(0, len(lst)-1):\n for j in range(i+1, len(lst)):\n if lst[i][1] < lst[j][1]:\n tmp = lst[i]\n lst[i] = lst[j]\n lst[j] = tmp\n return lst","assignment_id":4,"func_name":"sort_age","test":"assert sort_age([(\"F\", 19)])==[('F', 19)] and sort_age([(\"M\", 35), (\"F\", 18), (\"M\", 23), (\"F\", 19), (\"M\", 30), (\"M\", 17)])==[('M', 35), ('M', 30), ('M', 23), ('F', 19), ('F', 18), ('M', 17)] and sort_age([(\"F\", 18), (\"M\", 23), (\"F\", 19), (\"M\", 30), (\"M\", 17)])==[('M', 30), ('M', 23), ('F', 19), ('F', 18), ('M', 17)] and sort_age([(\"F\", 18), (\"M\", 23), (\"F\", 19), (\"M\", 30)])==[('M', 30), ('M', 23), ('F', 19), ('F', 18)] and sort_age([(\"M\", 23), (\"F\", 19), (\"M\", 30)])==[('M', 30), ('M', 23), ('F', 19)] and sort_age([])==[]","description":"Task: Sorting Tuples\n\n\nCan we sort items other than integers? For this question, you will be sorting tuples!\nWe represent a person using a tuple (<gender>, <age>). Given a list of people, write\na function sort_age that sorts the people and return a list in an order such that the older\npeople are at the front of the list. An example of the list of people is [(\"M\", 23), (\"F\",\n19), (\"M\", 30)]. The sorted list would look like [(\"M\", 30), (\"M\", 23), (\"F\", 19)]. You\nmay assume that no two members in the list of people are of the same age."}
|
5 |
+
{"reference_solution":"def top_k(lst, k):\n ls = []\n for i in range(k):\n ls.append(max(lst))\n lst.remove(max(lst))\n return ls","assignment_id":5,"func_name":"top_k","test":"import heapq\nassert top_k([9, 9, 4, 9, 7, 9, 3, 1, 6], 5)==[9, 9, 9, 9, 7] and top_k([9, 8, 4, 5, 7, 2, 3, 1, 6], 5)==[9, 8, 7, 6, 5] and top_k([4, 5, 2, 3, 1, 6], 6)==[6, 5, 4, 3, 2, 1] and top_k([4, 5, 2, 3, 1, 6], 3)==[6, 5, 4] and top_k([4, 5, 2, 3, 1, 6], 0)==[]","description":"Task: Top-K\n\n\nWrite a function top_k that accepts a list of integers as the input and returns the greatest\nk number of values as a list, with its elements sorted in descending order. You may use\nany sorting algorithm you wish, but you are not allowed to use sort and sorted."}
|
intro_prog.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
# coding=utf-8
|
2 |
-
# Copyright 2023 Charles Koutcheme
|
3 |
#
|
4 |
# Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
# you may not use this file except in compliance with the License.
|
@@ -19,12 +19,69 @@ import datasets
|
|
19 |
from itertools import product
|
20 |
|
21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
_DESCRIPTION = """
|
23 |
Intro Programming. A dataset of open student submissions to programming assignments.
|
24 |
|
25 |
"""
|
26 |
|
27 |
_DUBLIN_URLS = {
|
|
|
|
|
|
|
|
|
28 |
"data": {
|
29 |
"train": f"./data/dublin_data_train.jsonl",
|
30 |
"test": f"./data/dublin_data_test.jsonl",
|
@@ -36,6 +93,9 @@ _DUBLIN_URLS = {
|
|
36 |
}
|
37 |
|
38 |
_SINGAPORE_URLS = {
|
|
|
|
|
|
|
39 |
"data": {
|
40 |
"train": f"./data/singapore_data_train.jsonl",
|
41 |
},
|
@@ -67,7 +127,8 @@ class IntroProg(datasets.GeneratorBasedBuilder):
|
|
67 |
|
68 |
# splits "data", "repair", "bugs"
|
69 |
# also add here the "metadata" split which will also contain the full metadata
|
70 |
-
tasks = [("
|
|
|
71 |
("repair", "Buggy programs and ground truth repair(s)."),]
|
72 |
# ("bug", "Buggy programs and bug categories.")]
|
73 |
|
@@ -78,7 +139,7 @@ class IntroProg(datasets.GeneratorBasedBuilder):
|
|
78 |
BUILDER_CONFIGS.append(
|
79 |
IntroProgConfig(
|
80 |
name=f"{source}_{task}",
|
81 |
-
description=description,
|
82 |
version=VERSION,
|
83 |
)
|
84 |
)
|
@@ -86,28 +147,56 @@ class IntroProg(datasets.GeneratorBasedBuilder):
|
|
86 |
|
87 |
def _info(self):
|
88 |
|
89 |
-
|
90 |
-
"submission_id": datasets.Value("int32"),
|
91 |
-
"func_code": datasets.Value("string"),
|
92 |
-
|
93 |
-
# assignment information
|
94 |
-
"assignment_id": datasets.Value("string"),
|
95 |
-
"func_name": datasets.Value("string"),
|
96 |
-
"description": datasets.Value(dtype='string'),
|
97 |
-
"test": datasets.Value(dtype='string'),
|
98 |
-
})
|
99 |
-
|
100 |
-
if self.config.name.split("_")[1] == "repair":
|
101 |
-
features["annotation"] = datasets.Value("string")
|
102 |
-
if self.config.name.split("_")[1] == "bug":
|
103 |
-
features["comments"] = datasets.Value("string")
|
104 |
|
105 |
if self.config.name.split("_")[0] == "dublin":
|
106 |
-
|
107 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
|
109 |
return datasets.DatasetInfo(
|
110 |
-
description=
|
|
|
|
|
|
|
111 |
features=features,
|
112 |
supervised_keys=None,
|
113 |
)
|
|
|
1 |
# coding=utf-8
|
2 |
+
# Copyright 2023 Charles Koutcheme and the original authors of the datasets
|
3 |
#
|
4 |
# Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
# you may not use this file except in compliance with the License.
|
|
|
19 |
from itertools import product
|
20 |
|
21 |
|
22 |
+
|
23 |
+
_DUBLIN_DESCRIPTION = """
|
24 |
+
The Dublin programming dataset is a dataset composed of students' submissions
|
25 |
+
to introductory programming assignments at the University of Dublin.
|
26 |
+
Students submitted these programs for multiple programming courses over the duration of three academic years."""
|
27 |
+
|
28 |
+
_SINGAPORE_DESCRIPTION = """
|
29 |
+
This dataset contains 2442 correct and 1783 buggy program attempts by 361 undergraduate students crediting
|
30 |
+
an introduction to Python programming course at NUS (National University of Singapore).
|
31 |
+
"""
|
32 |
+
|
33 |
+
_DUBLIN_HOMEPAGE = """https://figshare.com/articles/dataset/_5_Million_Python_Bash_Programming_Submissions_for_5_Courses_Grades_for_Computer-Based_Exams_over_3_academic_years_/12610958"""
|
34 |
+
|
35 |
+
_SINGAPORE_HOMEPAGE = """https://github.com/githubhuyang/refactory"""
|
36 |
+
|
37 |
+
_DUBLIN_CITATION = """
|
38 |
+
@inproceedings{azcona2019user2code2vec,
|
39 |
+
title={user2code2vec: Embeddings for Profiling Students Based on Distributional Representations of Source Code},
|
40 |
+
author={Azcona, David and Arora, Piyush and Hsiao, I-Han and Smeaton, Alan},
|
41 |
+
booktitle={Proceedings of the 9th International Learning Analytics & Knowledge Conference (LAK’19)},
|
42 |
+
year={2019},
|
43 |
+
organization={ACM}
|
44 |
+
}
|
45 |
+
|
46 |
+
@inproceedings{DBLP:conf/edm/CleuziouF21,
|
47 |
+
author = {Guillaume Cleuziou and
|
48 |
+
Fr{\'{e}}d{\'{e}}ric Flouvat},
|
49 |
+
editor = {Sharon I{-}Han Hsiao and
|
50 |
+
Shaghayegh (Sherry) Sahebi and
|
51 |
+
Fran{\c{c}}ois Bouchet and
|
52 |
+
Jill{-}J{\^{e}}nn Vie},
|
53 |
+
title = {Learning student program embeddings using abstract execution traces},
|
54 |
+
booktitle = {Proceedings of the 14th International Conference on Educational Data
|
55 |
+
Mining, {EDM} 2021, virtual, June 29 - July 2, 2021},
|
56 |
+
publisher = {International Educational Data Mining Society},
|
57 |
+
year = {2021},
|
58 |
+
timestamp = {Wed, 09 Mar 2022 16:47:22 +0100},
|
59 |
+
biburl = {https://dblp.org/rec/conf/edm/CleuziouF21.bib},
|
60 |
+
bibsource = {dblp computer science bibliography, https://dblp.org}
|
61 |
+
}
|
62 |
+
"""
|
63 |
+
|
64 |
+
_SINGAPORE_CITATION = """
|
65 |
+
@inproceedings{yang2019refactory,
|
66 |
+
title={Re-factoring based Program Repair applied to Programming Assignments},
|
67 |
+
author={Hu, Yang and Ahmed, Umair Z. and Mechtaev, Sergey and Leong, Ben and Roychoudhury, Abhik},
|
68 |
+
booktitle={2019 34th IEEE/ACM International Conference on Automated Software Engineering (ASE)},
|
69 |
+
pages={388--398},
|
70 |
+
year={2019},
|
71 |
+
organization={IEEE/ACM}
|
72 |
+
}
|
73 |
+
"""
|
74 |
+
|
75 |
_DESCRIPTION = """
|
76 |
Intro Programming. A dataset of open student submissions to programming assignments.
|
77 |
|
78 |
"""
|
79 |
|
80 |
_DUBLIN_URLS = {
|
81 |
+
"metadata": {
|
82 |
+
"train": "./data/dublin_metadata_train.jsonl",
|
83 |
+
"test": "./data/dublin_metadata_test.jsonl"
|
84 |
+
},
|
85 |
"data": {
|
86 |
"train": f"./data/dublin_data_train.jsonl",
|
87 |
"test": f"./data/dublin_data_test.jsonl",
|
|
|
93 |
}
|
94 |
|
95 |
_SINGAPORE_URLS = {
|
96 |
+
"metadata": {
|
97 |
+
"train": "./data/singapore_metadata_train.jsonl",
|
98 |
+
},
|
99 |
"data": {
|
100 |
"train": f"./data/singapore_data_train.jsonl",
|
101 |
},
|
|
|
127 |
|
128 |
# splits "data", "repair", "bugs"
|
129 |
# also add here the "metadata" split which will also contain the full metadata
|
130 |
+
tasks = [("metadata", "Information about the programming assignments."),
|
131 |
+
("data", "Submissions to the programming assignments."),
|
132 |
("repair", "Buggy programs and ground truth repair(s)."),]
|
133 |
# ("bug", "Buggy programs and bug categories.")]
|
134 |
|
|
|
139 |
BUILDER_CONFIGS.append(
|
140 |
IntroProgConfig(
|
141 |
name=f"{source}_{task}",
|
142 |
+
# description=description, # TODO: map to correct description
|
143 |
version=VERSION,
|
144 |
)
|
145 |
)
|
|
|
147 |
|
148 |
def _info(self):
|
149 |
|
150 |
+
# TODO: could be more conscise
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
|
152 |
if self.config.name.split("_")[0] == "dublin":
|
153 |
+
description = _DUBLIN_DESCRIPTION
|
154 |
+
citation = _DUBLIN_CITATION
|
155 |
+
homepage = _DUBLIN_HOMEPAGE
|
156 |
+
elif self.config.name.split("_")[0] == "singapore":
|
157 |
+
description =_SINGAPORE_DESCRIPTION
|
158 |
+
citation = _SINGAPORE_CITATION
|
159 |
+
homepage = _SINGAPORE_HOMEPAGE
|
160 |
+
|
161 |
+
|
162 |
+
main_features = datasets.Features({
|
163 |
+
"submission_id": datasets.Value("int32"),
|
164 |
+
"func_code": datasets.Value("string"),
|
165 |
+
# assignment information
|
166 |
+
"assignment_id": datasets.Value("string"),
|
167 |
+
"func_name": datasets.Value("string"),
|
168 |
+
"description": datasets.Value(dtype='string'),
|
169 |
+
"test": datasets.Value(dtype='string'),
|
170 |
+
})
|
171 |
+
|
172 |
+
if self.config.name.split("_")[1] == "data":
|
173 |
+
features = main_features
|
174 |
+
if self.config.name.split("_")[0] == "dublin":
|
175 |
+
features["user"] = datasets.Value("string")
|
176 |
+
features["academic_year"] = datasets.Value('int32')
|
177 |
+
|
178 |
+
elif self.config.name.split("_")[1] == "metadata":
|
179 |
+
# metadata information
|
180 |
+
features = datasets.Features({
|
181 |
+
"assignment_id": datasets.Value("string"),
|
182 |
+
"func_name": datasets.Value("string"),
|
183 |
+
"reference_solution": datasets.Value("string"),
|
184 |
+
"description": datasets.Value("string"),
|
185 |
+
"test": datasets.Value("string"),
|
186 |
+
})
|
187 |
+
|
188 |
+
elif self.config.name.split("_")[1] == "repair":
|
189 |
+
features = main_features
|
190 |
+
features["annotation"] = datasets.Value("string")
|
191 |
+
elif self.config.name.split("_")[1] == "bug":
|
192 |
+
features = main_features
|
193 |
+
features["comments"] = datasets.Value("string")
|
194 |
|
195 |
return datasets.DatasetInfo(
|
196 |
+
description=description,
|
197 |
+
citation=citation,
|
198 |
+
homepage=homepage,
|
199 |
+
|
200 |
features=features,
|
201 |
supervised_keys=None,
|
202 |
)
|