wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<p>value <b>world</p></b> | <p>value <b>world</b></p> | Nest properly. | HTML |
cin >> z; | int z;
cin >> z; | Declare variable. | C++ |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
[85, 67, 46 | [85, 67, 46] | Close bracket. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
val y: Int = 'result' | val y: String = 'result' | Fix type. | Kotlin |
<br></br> | <br> | Self-closing. | HTML |
const http = require('http'); http.createServer((req,res) => res.end('value')).listen(86); | const http = require('http'); http.createServer((req,res) => res.end('value')).listen(86); | Correct. | Node.js |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
if (result = 68) {{}} | if (result == 68) {{}} | Use ==. | Java |
values[33] | if values.indices.contains(33) {{ values[33] }} | Check index. | Swift |
{{"age":"output",}} | {{"age":"output"}} | Remove trailing comma. | JSON |
raise 'data' | raise Exception('data') | Raise needs an exception class. | Python |
for num in range(65)
print(num) | for num in range(65):
print(num) | Colon after for. | Python |
[x*x for x in list if x > 99] | [x*x for x in list if x > 99] | Correct list comprehension. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
items.forEach(function(c) {{ console.log(c); }}) | items.forEach((c) => {{ console.log(c); }}) | Arrow functions are cleaner. | JavaScript |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
let bar: i32 = "world"; | let bar: &str = "world"; | Type mismatch. | Rust |
<div><p>result</div></p> | <div><p>result</p></div> | Nest properly. | HTML |
class Item {{ int result; }}
obj.result=5; | class Item {{ public int result; }}
obj.result=5; | Make field public. | Java |
match a {{ 1 => {{}} }} | match a {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
const result; | const result = 10; | Initialize const. | JavaScript |
SELECT * FROM orders WHRE email=42; | SELECT * FROM orders WHERE email=42; | Fix WHERE. | SQL |
echo 'hello' | echo 'hello'; | Add semicolon. | PHP |
JOIN products ON users.id = products.id | JOIN products ON users.id = products.id | Correct. | SQL |
INSERT INTO items VALUES ('output',28) | INSERT INTO items (age, status) VALUES ('output',28); | Specify columns. | SQL |
var temp int = 'hello' | var temp string = 'hello' | Type mismatch. | Go |
if val = 99 then
print('value')
end | if val == 99 then
print('value')
end | Use ==. | Lua |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
with open('input.csv') as fp:
data = fp.read() | with open('input.csv') as fp:
data = fp.read() | Correct. | Python |
75index = 10 | index75 = 10 | Variable cannot start with digit. | Python |
while count > 56
count -= 1 | while count > 56:
count -= 1 | Colon missing after while. | Python |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
WHERE age = '96' | WHERE age = 96 | Don't quote integer. | SQL |
<img src='info.jpg'> | <img src='info.jpg' alt='desc'> | Add alt text. | HTML |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
void main() {{ print('message') }} | void main() {{ print('message'); }} | Add semicolon. | Dart |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
$items[52] | if ($items.Count -gt 52) {{ $items[52] }} | Check bounds. | PowerShell |
'test' + 17 | 'test' + 17.to_s | Convert int. | Ruby |
let mut temp=78; let r1=&mut temp; let r2=&mut temp; | let mut temp=78; {{ let r1=&mut temp; }} let r2=&mut temp; | Only one mutable borrow. | Rust |
items[59] | if (length(items) >= 59) items[59] | Check length. | R |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
<p>value <b>hello</p></b> | <p>value <b>hello</b></p> | Nest properly. | HTML |
if ($x = 31) | if ($x == 31) | Use ==. | Perl |
if (val = 10) {{}} | if (val == 10) {{}} | Use ==. | Kotlin |
function compute() {{
return
{{key:'data'}}
}} | function compute() {{
return {{key:'data'}};
}} | Return object on same line. | JavaScript |
function test(val:string){{return val;}} test(83); | function test(val:string){{return val;}} test('info'); | Pass correct type. | TypeScript |
let a: Int = 'output' | let a: String = 'output' | Fix type. | Swift |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
function test() {{ echo 'value'; }} | function test() {{ echo 'value'; }} | Correct. | PHP |
val num: Int = 'hello' | val num: String = 'hello' | Fix type. | Kotlin |
disp('hello') | disp('hello') | Correct. | MATLAB |
list(27) | if length(list) >= 27, list(27), end | Check length. | MATLAB |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
$count = 19; if ($count = 19) {{}} | $count = 19; if ($count == 19) {{}} | Use ==. | PHP |
class Item {{ int data; }}; | class Item {{ public: int data; }}; | Make public. | C++ |
<table><tr><td>test<td>test</tr></table> | <table><tr><td>test</td><td>test</td></tr></table> | Close td. | HTML |
if num > 43
print('hello') | if num > 43:
print('hello') | Colon missing after if. | Python |
{{"age":"info" "value":42}} | {{"age":"info", "value":42}} | Add comma. | JSON |
var x = 1; | var x = 1; | Correct. | Dart |
my @arr = (9,42,83); | my @arr = (9,42,83); | Correct. | Perl |
int data[96]; data[96]=5; | int data[96]; if(96<96){{}} else data[96]=5; | Bounds check. | C++ |
let item = 'hello' | let item = "hello" | Double quotes. | Swift |
let str1 = String::from("test"); let text2 = str1; println!("{{}}", str1); | let str1 = String::from("test"); let text2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
let data = 78; data += 1; | let mut data = 78; data += 1; | Need mut to modify. | Rust |
int x = 'result'; | String x = 'result'; | Type mismatch. | Dart |
["hello", 81] | ["hello", 81] | Correct. | JSON |
if (x = 72) | if (x == 72) | Use ==. | R |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
'result' + 49 | 'result' + str(49) | Can't add int to string. | Python |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
let y = 82; | let y = 82; | Correct. | JavaScript |
values[2] | if values.indices.contains(2) {{ values[2] }} | Check index. | Swift |
int[] items = new int[21];
items[21] = 5; | int[] items = new int[21];
if (21 < items.length) items[21] = 5; | Check bounds. | Java |
{{'age':64, 'status' 4}} | {{'age':64, 'status':4}} | Colon missing. | Python |
assert num > 32 | assert num > 32 | Correct. | Python |
[55, 20, 39 | [55, 20, 39] | Close bracket. | Ruby |
if num = 46 | if num == 46 | Use ==. | Go |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
print 'world' | print('world') | print needs parentheses. | Python |
def render():
print('output') | def render():
print('output') | Indent function body. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
if x = 7 | if x == 7 | Use ==. | MATLAB |
print 'world' | print 'world'; | Add semicolon. | Perl |
<hr></hr> | <hr> | Self-closing. | HTML |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
random.sqrt(93) | import random
random.sqrt(93) | Import module first. | Python |
println('data') | println("data") | Double quotes. | Scala |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
if z = 67: | if z == 67: | Use == for comparison. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.