198 lines
7.1 KiB
JSON
198 lines
7.1 KiB
JSON
[
|
|
{
|
|
"task_id": 1,
|
|
"text": "Captura el parámetro 'username' de la petición HTTP y devuélvelo como resultado. Si no existe, la variable será None.",
|
|
"code": "addParam(\"username\", username)\naddResult(username)",
|
|
"test_inputs": {
|
|
"username": "alice"
|
|
},
|
|
"test_list": [
|
|
"re.match(r'^alice$', str(username))"
|
|
]
|
|
},
|
|
{
|
|
"task_id": 2,
|
|
"text": "Recibe el parámetro 'email' y establece el código de estado HTTP en 200. Devuelve el email como resultado.",
|
|
"code": "addParam(\"email\", email)\naddVar(_status, 200)\naddResult(email)",
|
|
"test_inputs": {
|
|
"email": "user@example.com"
|
|
},
|
|
"test_list": [
|
|
"re.match(r'^user@example\\.com$', str(email))",
|
|
"re.match(r'^200$', str(_status))"
|
|
]
|
|
},
|
|
{
|
|
"task_id": 3,
|
|
"text": "Recibe el parámetro 'password', genera su hash SHA-256 y devuelve el hash como resultado.",
|
|
"code": "addParam(\"password\", password)\nencodeSHA256(password, hashed)\naddResult(hashed)",
|
|
"test_inputs": {
|
|
"password": "secret123"
|
|
},
|
|
"test_list": [
|
|
"re.match(r'^[a-f0-9]{64}$', str(hashed))"
|
|
]
|
|
},
|
|
{
|
|
"task_id": 4,
|
|
"text": "Recibe el parámetro 'text', reemplaza todos los espacios por guiones bajos y devuelve el resultado.",
|
|
"code": "addParam(\"text\", text)\nreplace(text, \" \", \"_\", result)\naddResult(result)",
|
|
"test_inputs": {
|
|
"text": "hello world foo"
|
|
},
|
|
"test_list": [
|
|
"re.match(r'^hello_world_foo$', str(result))"
|
|
]
|
|
},
|
|
{
|
|
"task_id": 5,
|
|
"text": "Genera un token aleatorio de 32 caracteres alfanuméricos y devuélvelo como resultado.",
|
|
"code": "randomString(\"[a-zA-Z0-9]\", 32, token)\naddResult(token)",
|
|
"test_inputs": {},
|
|
"test_list": [
|
|
"re.match(r'^[a-zA-Z0-9]{32}$', str(token))"
|
|
]
|
|
},
|
|
{
|
|
"task_id": 6,
|
|
"text": "Recibe el parámetro 'age'. Si age es mayor que 18, devuelve 'adulto'; de lo contrario devuelve 'menor'.",
|
|
"code": "addParam(\"age\", age)\nif(age, 18, \">\")\nresult = \"adulto\"\nelse()\nresult = \"menor\"\nend()\naddResult(result)",
|
|
"test_inputs": {
|
|
"age": 25
|
|
},
|
|
"test_list": [
|
|
"re.match(r'^adulto$', str(result))"
|
|
]
|
|
},
|
|
{
|
|
"task_id": 7,
|
|
"text": "Recibe el parámetro 'score'. Si score es igual a 100, establece _status en 200 y result en 'perfecto'; si no, _status en 400 y result en 'incompleto'.",
|
|
"code": "addParam(\"score\", score)\nif(score, 100, \"==\")\naddVar(_status, 200)\nresult = \"perfecto\"\nelse()\naddVar(_status, 400)\nresult = \"incompleto\"\nend()\naddResult(result)",
|
|
"test_inputs": {
|
|
"score": 100
|
|
},
|
|
"test_list": [
|
|
"re.match(r'^perfecto$', str(result))",
|
|
"re.match(r'^200$', str(_status))"
|
|
]
|
|
},
|
|
{
|
|
"task_id": 8,
|
|
"text": "Crea una lista con el elemento 'item1', obtén su longitud y devuelve la longitud como resultado.",
|
|
"code": "variableToList(\"item1\", myList)\ngetListLen(myList, length)\naddResult(length)",
|
|
"test_inputs": {},
|
|
"test_list": [
|
|
"re.match(r'^1$', str(length))"
|
|
]
|
|
},
|
|
{
|
|
"task_id": 10,
|
|
"text": "Recibe el parámetro 'data' como JSON, extrae el campo 'name' y devuélvelo como resultado.",
|
|
"code": "addParam(\"data\", data)\nvariableFromJSON(data, \"name\", name)\naddResult(name)",
|
|
"test_inputs": {
|
|
"data": "{\"name\": \"Carlos\", \"age\": 30}"
|
|
},
|
|
"test_list": [
|
|
"re.match(r'^Carlos$', str(name))"
|
|
]
|
|
},
|
|
{
|
|
"task_id": 12,
|
|
"text": "Recibe el parámetro 'password', genera su hash MD5 y devuelve el hash como resultado.",
|
|
"code": "addParam(\"password\", password)\nencodeMD5(password, hashed)\naddResult(hashed)",
|
|
"test_inputs": {
|
|
"password": "mypassword"
|
|
},
|
|
"test_list": [
|
|
"re.match(r'^[a-f0-9]{32}$', str(hashed))"
|
|
]
|
|
},
|
|
{
|
|
"task_id": 14,
|
|
"text": "Recibe el parámetro 'epoch', conviértelo a string de fecha en formato 'YYYY-MM-DD HH:MM:SS' y devuelve el resultado.",
|
|
"code": "addParam(\"epoch\", epoch)\nstampToDatetime(epoch, \"%Y-%m-%d %H:%M:%S\", 0, datestr)\naddResult(datestr)",
|
|
"test_inputs": {
|
|
"epoch": 1700000000
|
|
},
|
|
"test_list": [
|
|
"re.match(r'^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}$', str(datestr))"
|
|
]
|
|
},
|
|
{
|
|
"task_id": 16,
|
|
"text": "Define una función que recibe un número y devuelve su cuadrado. Llama a la función con el parámetro 'n' y devuelve el resultado.",
|
|
"code": "function square(n) {\nresult = n * n\nreturn(result)\n}\naddParam(\"n\", n)\nsquared = square(n)\naddResult(squared)",
|
|
"test_inputs": {
|
|
"n": 7
|
|
},
|
|
"test_list": [
|
|
"re.match(r'^49$', str(squared))"
|
|
]
|
|
},
|
|
{
|
|
"task_id": 17,
|
|
"text": "Define una función que recibe dos números y devuelve su suma. Llama a la función con los parámetros 'a' y 'b' y devuelve el resultado.",
|
|
"code": "function add(a, b) {\nresult = a + b\nreturn(result)\n}\naddParam(\"a\", a)\naddParam(\"b\", b)\nsum = add(a, b)\naddResult(sum)",
|
|
"test_inputs": {
|
|
"a": 15,
|
|
"b": 27
|
|
},
|
|
"test_list": [
|
|
"re.match(r'^42$', str(sum))"
|
|
]
|
|
},
|
|
{
|
|
"task_id": 18,
|
|
"text": "Usa un bloque try/exception para intentar dividir el parámetro 'num' entre 0. Si ocurre error, devuelve 'error_division'.",
|
|
"code": "addParam(\"num\", num)\ntry()\nresult = num / 0\nexception(err)\nresult = \"error_division\"\nend()\naddResult(result)",
|
|
"test_inputs": {
|
|
"num": 10
|
|
},
|
|
"test_list": [
|
|
"re.match(r'^error_division$', str(result))"
|
|
]
|
|
},
|
|
{
|
|
"task_id": 19,
|
|
"text": "Recibe el parámetro 'url', realiza una petición GET a esa URL con timeout de 5000ms y devuelve la respuesta.",
|
|
"code": "addParam(\"url\", url)\nRequestGet(url, \"\", \"\", response, 5000)\naddResult(response)",
|
|
"test_inputs": {
|
|
"url": "https://httpbin.org/get"
|
|
},
|
|
"test_list": [
|
|
"re.match(r'^.*$', str(response))"
|
|
]
|
|
},
|
|
{
|
|
"task_id": 20,
|
|
"text": "Recibe los parámetros 'url' y 'body', realiza una petición POST con timeout de 3000ms y devuelve la respuesta.",
|
|
"code": "addParam(\"url\", url)\naddParam(\"body\", body)\nRequestPost(url, \"\", \"\", body, response, 3000)\naddResult(response)",
|
|
"test_inputs": {
|
|
"url": "https://httpbin.org/post",
|
|
"body": "{\"key\":\"value\"}"
|
|
},
|
|
"test_list": [
|
|
"re.match(r'^.*$', str(response))"
|
|
]
|
|
},
|
|
{
|
|
"task_id": 28,
|
|
"text": "Importa la librería nativa 'math', calcula el cuadrado de 9 usando una función y devuelve el resultado.",
|
|
"code": "import <math>\nfunction calcSquare(x) {\nresult = x * x\nreturn(result)\n}\nresult = calcSquare(9)\naddResult(result)",
|
|
"test_inputs": {},
|
|
"test_list": [
|
|
"re.match(r'^81$', str(result))"
|
|
]
|
|
},
|
|
{
|
|
"task_id": 29,
|
|
"text": "Recibe el parámetro 'items_json' como JSON con una lista bajo la clave 'items'. Extrae la lista, obtén su longitud y devuelve la longitud.",
|
|
"code": "addParam(\"items_json\", items_json)\nvariableFromJSON(items_json, \"items\", items)\ngetListLen(items, length)\naddResult(length)",
|
|
"test_inputs": {
|
|
"items_json": "{\"items\": [\"x\", \"y\", \"z\"]}"
|
|
},
|
|
"test_list": [
|
|
"re.match(r'^3$', str(length))"
|
|
]
|
|
}
|
|
] |