docs / familias / code

code — Programming exercises with tests

Auto-gradable programming exercises: statement, language, test expressions, expected type and hints.

Dominio
education / programming
Versión
1
Padre
— (raíz)
Clave de registros
exercises
Separador de lista
,
Archivo
forks/code/contract.json

Campos por posición

#TipoDescripciónParte
idstr (unique: True)núcleo
bloomenum (valores: L1, L2, L3, L4, L5, L6)núcleo
topicstrnúcleo
statementstrnúcleo
langenum (valores: python, javascript, java, sql, c, cpp, go)núcleo
testslistboolean test expressions (min: 1 · max: 10)núcleo
expectedstrnúcleo
hintslist (max: 5)núcleo

Ejemplo válido

code|n=12|d=20260603|l=en|t=Intro programming lab 3
c1|L3|lists|Write a function maximum(xs) that returns the largest number in a non-empty list.|python|maximum([2\,8\,3])==8,maximum([-1\,-5])==-1|int or float|iterate once,track the best so far
c2|L3|strings|Write is_palindrome(s) ignoring case and spaces.|python|is_palindrome('Anita lava la tina'),not is_palindrome('hello')|bool|normalize first
c3|L2|arithmetic|Return the sum of the digits of a positive integer.|python|digit_sum(1234)==10,digit_sum(7)==7|int|
c4|L4|recursion|Implement fib(n) iteratively with O(1) memory.|python|fib(10)==55,fib(0)==0|int|two variables suffice
c5|L3|dictionaries|Count word frequencies in a text and return a dict.|python|word_count('a b a')=={'a':2\,'b':1}|dict|split on whitespace
c6|L5|sorting|Sort a list of (name, score) tuples by score descending, then name.|python|rank([('b'\,1)\,('a'\,1)\,('c'\,2)])==[('c'\,2)\,('a'\,1)\,('b'\,1)]|list|use a key function
c7|L3|arrays|Return the second largest distinct element of an array.|javascript|secondLargest([3\,1\,3\,2])===2|number|deduplicate first
c8|L2|conditionals|Classify a temperature in Celsius as cold, mild or hot.|javascript|classify(5)==='cold',classify(30)==='hot'|string|
c9|L4|regex|Validate an email address with a regular expression.|javascript|isEmail('a@b.co')===true,isEmail('a@b')===false|boolean|require a dot in the domain
c10|L5|algorithms|Implement binary search returning the index or -1.|java|binarySearch(new int[]{1\,3\,5}\,5)==2,binarySearch(new int[]{1\,3\,5}\,4)==-1|int|halve the interval
c11|L6|design|Design a Stack class with push, pop and peek using an array.|java|new Stack().push(1).pop()==1|class|track the top index,throw on empty pop
c12|L3|sql|Return the names of students with an average grade above 14.|sql|rows==3|result set|GROUP BY student,HAVING AVG(grade)>14

Cárgalo en el playground o valida con mini validate forks/code/fixtures/valid.mini.

Notas de la familia

.mini-code — Programming exercises with tests#

Prefix: code Version: 1 Parent:Domain: education / programming

Auto-gradable programming exercises: statement, language, test expressions, expected type and hints.

Record layout#

id:str | bloom:enum{L1|L2|L3|L4|L5|L6} | topic:str | statement:str | lang:enum{python|javascript|java|sql|c|cpp|go} | tests:list<str>[1..10] | expected:str | hints:list<str>[0..5]
# field type notes
1 id str core
2 bloom enum{L1|L2|L3|L4|L5|L6} core
3 topic str core
4 statement str core
5 lang enum{python|javascript|java|sql|c|cpp|go} core
6 tests list<str>[1..10] core; boolean test expressions
7 expected str core
8 hints list<str>[0..5] core

Header keys#

key type required description
d str no generation date YYYYMMDD
l str no language code
t str no
n int yes number of records
v int no contract version

Example#

code|n=12|d=20260603|l=en|t=Intro programming lab 3
c1|L3|lists|Write a function maximum(xs) that returns the largest number in a non-empty list.|python|maximum([2\,8\,3])==8,maximum([-1\,-5])==-1|int or float|iterate once,track the best so far
c2|L3|strings|Write is_palindrome(s) ignoring case and spaces.|python|is_palindrome('Anita lava la tina'),not is_palindrome('hello')|bool|normalize first
…

Fixtures#

fixtures/valid.minifixtures/canonical.json (round-trip), fixtures/escaping.minifixtures/escaping.json, and the negative cases bad_count.mini, bad_arity.mini, bad_type.mini.

Prompt block#

Generate the transferable specification with mini prompt code.