id int64 1 50 | task stringlengths 12 66 | code stringlengths 31 113 | language stringclasses 3
values | errors stringlengths 2 108 |
|---|---|---|---|---|
1 | Add two numbers | def add(a, b):
return a + b | python | [] |
2 | Check if a number is even | def is_even(n):
return n % 2 == 0 | python | [] |
3 | Retrieve the first element of a list | def get_first(items):
return items[0] | python | [] |
4 | Square a number if it is positive | def square_pos(n):
if n > 0
return n * n
return n | python | [{"line": 2, "error_code": "PY_MISSING_COLON"}] |
5 | Create a list containing 1, 2, and 3 | def get_list():
return [1, 2, 3 | python | [{"line": 2, "error_code": "PY_UNMATCHED_BRACKET"}] |
6 | Return double of x | def double(x):
y = x * 2
return y | python | [{"line": 3, "error_code": "PY_BAD_INDENTATION"}] |
7 | Add 10 to a number | def add_ten(n):
return n + ten | python | [{"line": 2, "error_code": "PY_UNDEFINED_VARIABLE"}] |
8 | Greet a user with their username | def greet(username):
return "Hello " + user_name | python | [{"line": 2, "error_code": "PY_WRONG_VARIABLE_NAME"}] |
9 | Call format_name with first and last name | def format_name(first, last):
return first + " " + last
res = format_name("Alice") | python | [{"line": 3, "error_code": "PY_MISSING_ARGUMENT"}] |
10 | Compute square of x | def square(x):
return x * x
val = square(5, 10) | python | [{"line": 3, "error_code": "PY_EXTRA_ARGUMENT"}] |
11 | Calculate the product of a and b | def multiply(a, b):
return a + b | python | [{"line": 2, "error_code": "PY_WRONG_OPERATOR"}] |
12 | Count down to zero starting from n | def count_down(n):
while n > 0:
print(n) | python | [{"line": 2, "error_code": "PY_INFINITE_LOOP"}] |
13 | Sum numbers from 1 to n | def sum_to_n(n):
total = 0
for i in range(n):
total += i
return total - 1 | python | [{"line": 3, "error_code": "PY_OFF_BY_ONE"}, {"line": 5, "error_code": "PY_WRONG_RETURN_VALUE"}] |
14 | Divide the first element of list A by the second element of list B | def get_ratio(lst):
divisor = 5 - 5
num = lst[len(lst)]
return num / divisor | python | [{"line": 3, "error_code": "PY_INDEX_OUT_OF_RANGE"}, {"line": 4, "error_code": "PY_DIVISION_BY_ZERO"}] |
15 | Append a number to a list and return its string representation | def append_to_list(val, lst=[]):
lst.append(val)
return "List: " + lst | python | [{"line": 1, "error_code": "PY_MUTABLE_DEFAULT_ARGUMENT"}, {"line": 3, "error_code": "PY_TYPE_MISMATCH"}] |
16 | Print warning if speed is over limit | def check_speed(speed):
if speed > 120
print("Too fast!") | python | [{"line": 2, "error_code": "PY_MISSING_COLON"}, {"line": 3, "error_code": "PY_BAD_INDENTATION"}] |
17 | Compute the sum of elements in a range | def sum_range(n):
return sum(range(n)
total_sum = sum_range(limit) | python | [{"line": 2, "error_code": "PY_UNMATCHED_BRACKET"}, {"line": 3, "error_code": "PY_UNDEFINED_VARIABLE"}] |
18 | Add two numbers | function add(a, b) {
return a + b;
} | javascript | [] |
19 | Calculate square of a number | const square = (n) => {
return n * n;
}; | javascript | [] |
20 | Fetch data asynchronously | async function getData(url) {
return await fetch(url);
} | javascript | [] |
21 | Check if a number is positive | function isPositive(n) {
if (n > 0) {
return true;
} | javascript | [{"line": 4, "error_code": "JS_MISSING_BRACE"}] |
22 | Log user age | function logAge(user) {
console.log(user.name + " is " + age);
} | javascript | [{"line": 2, "error_code": "JS_UNDEFINED_VARIABLE"}] |
23 | Check if value is five | function isFive(x) {
if (x = 5) return true;
return false;
} | javascript | [{"line": 2, "error_code": "JS_WRONG_COMPARISON"}] |
24 | Fetch configuration asynchronously | async function getConfig() {
const config = fetch("/config");
return config;
} | javascript | [{"line": 2, "error_code": "JS_ASYNC_WITHOUT_AWAIT"}] |
25 | Get greeting string | function getGreeting(name) {
const msg = "Hello " + name;
} | javascript | [{"line": 2, "error_code": "JS_MISSING_RETURN"}] |
26 | Access object property safely | function printLength(obj) {
let val = null;
return val.length;
} | javascript | [{"line": 3, "error_code": "JS_NULL_ACCESS"}] |
27 | Loop through an array and print elements | function printAll(arr) {
for (let i = 0; i <= arr.length; i++) {
console.log(arr[i]);
}
} | javascript | [{"line": 2, "error_code": "JS_OFF_BY_ONE"}] |
28 | Repeat printing until flag is true | function repeatMsg() {
while (true) {
console.log("working");
}
} | javascript | [{"line": 2, "error_code": "JS_INFINITE_LOOP"}] |
29 | Calculate sum of three numbers | function sum3(a, b, c) {
return a + b + c;
}
const total = sum3(1, 2); | javascript | [{"line": 4, "error_code": "JS_WRONG_ARGUMENT_COUNT"}] |
30 | Display user description | function showInfo(user) {
if (user) {
console.log(user.name + " is " + role);
} | javascript | [{"line": 3, "error_code": "JS_UNDEFINED_VARIABLE"}, {"line": 4, "error_code": "JS_MISSING_BRACE"}] |
31 | Verify token and return true if verified | async function checkToken() {
const token = getTokenFromServer();
if (token == NaN) return true;
} | javascript | [{"line": 2, "error_code": "JS_ASYNC_WITHOUT_AWAIT"}, {"line": 3, "error_code": "JS_WRONG_COMPARISON"}] |
32 | Get item price from config | function getPrice() {
const item = null;
const val = item.price;
} | javascript | [{"line": 3, "error_code": "JS_NULL_ACCESS"}, {"line": 4, "error_code": "JS_MISSING_RETURN"}] |
33 | Count active sessions in a list | function countSessions(lst) {
while (true) {
let x = lst[lst.length];
}
} | javascript | [{"line": 2, "error_code": "JS_INFINITE_LOOP"}, {"line": 3, "error_code": "JS_OFF_BY_ONE"}] |
34 | Format name with user initials and role | function format(initials, role) {
return initials + " (" + job + ")";
}
format("JD"); | javascript | [{"line": 2, "error_code": "JS_UNDEFINED_VARIABLE"}, {"line": 4, "error_code": "JS_WRONG_ARGUMENT_COUNT"}] |
35 | Add two numbers | int add(int a, int b) {
return a + b;
} | java | [] |
36 | Check if a string is empty | boolean isEmpty(String str) {
return str.isEmpty();
} | java | [] |
37 | Find the maximum of two numbers | int max(int x, int y) {
return (x > y) ? x : y;
} | java | [] |
38 | Get array length | int getLength(int[] arr) {
return arr.length;
} | java | [] |
39 | Return double of a number | int doubleVal(int x) {
return x * 2
} | java | [{"line": 2, "error_code": "JAVA_MISSING_SEMICOLON"}] |
40 | Compute square of a positive number | int square(int x) {
if (x > 0) {
return x * x;
} | java | [{"line": 4, "error_code": "JAVA_MISSING_BRACE"}] |
41 | Compute area of a circle given radius | double getArea(double r) {
return PI * r * r;
} | java | [{"line": 2, "error_code": "JAVA_UNDEFINED_VARIABLE"}] |
42 | Check if two strings are equal | boolean compareStrings(String a, String b) {
return a == b;
} | java | [{"line": 2, "error_code": "JAVA_WRONG_COMPARISON"}] |
43 | Get username length safely | int getNameLength() {
String name = null;
return name.length();
} | java | [{"line": 3, "error_code": "JAVA_NULL_ACCESS"}] |
44 | Sum up elements of array | int sumArray(int[] arr) {
int sum = 0;
for (int i = 0; i <= arr.length; i++) sum += arr[i];
return sum;
} | java | [{"line": 3, "error_code": "JAVA_OFF_BY_ONE"}] |
45 | Loop until condition is met | void loop(int x) {
while (x > 0) {
System.out.println(x);
}
} | java | [{"line": 2, "error_code": "JAVA_INFINITE_LOOP"}] |
46 | Retrieve the first element of the array | int getFirst(int[] arr) {
int val = arr[-1];
} | java | [{"line": 2, "error_code": "JAVA_INDEX_OUT_OF_RANGE"}, {"line": 3, "error_code": "JAVA_MISSING_RETURN"}] |
47 | Convert boolean to integer status code | int getStatus(boolean ok) {
int status = ok
return status;
} | java | [{"line": 2, "error_code": "JAVA_TYPE_MISMATCH"}, {"line": 2, "error_code": "JAVA_MISSING_SEMICOLON"}] |
48 | Compute the average of total elements | double getAvg(double sum, int count) {
return sum / (count - count);
}
double result = getAvg(10.0); | java | [{"line": 2, "error_code": "JAVA_DIVISION_BY_ZERO"}, {"line": 4, "error_code": "JAVA_WRONG_ARGUMENT_COUNT"}] |
49 | Process items if active | void process(boolean active) {
if (active) {
int total = count + 1;
} | java | [{"line": 3, "error_code": "JAVA_UNDEFINED_VARIABLE"}, {"line": 4, "error_code": "JAVA_MISSING_BRACE"}] |
50 | Check if name is empty safely | boolean checkName(String val) {
String text = null;
if (val == text) return text.isEmpty();
return false;
} | java | [{"line": 3, "error_code": "JAVA_WRONG_COMPARISON"}, {"line": 3, "error_code": "JAVA_NULL_ACCESS"}] |
README.md exists but content is empty.
- Downloads last month
- 38