wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
fn compute() -> i32 {{ 11 }} | fn compute() -> i32 {{ 11 }} | Correct. | Rust |
String index = 'world'; | String index = "world"; | Double quotes. | Java |
if y > 29
puts 'value' | if y > 29
puts 'value'
end | Add 'end'. | Ruby |
<person age=70> | <person age="70"> | Quote attribute. | XML |
print 'output' | print('output') | print needs parentheses. | Python |
let c: Int = 'data' | let c: String = 'data' | Fix type. | Swift |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
b > 10 & b < 71 | b > 10 and b < 71 | Use 'and' not '&'. | Python |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
h1 {{ font-size:32px color:blue; }} | h1 {{ font-size:32px; color:blue; }} | Add semicolon. | CSS |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
$data[24] | if ($data.Count -gt 24) {{ $data[24] }} | Check bounds. | PowerShell |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
print 'value' | print 'value'; | Add semicolon. | Perl |
58val = 10 | val58 = 10 | Variable cannot start with digit. | Python |
[97, 88, 93 | [97, 88, 93] | Close bracket. | Python |
try {{ throw 'message'; }} catch(e) {{}} | try {{ throw new Error('message'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
let v=vec![83,95,10]; let head=&v[0]; v.push(86); | let mut v=vec![83,95,10]; let head=v[0]; v.push(86); | Copy instead of reference. | Rust |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
INSERT INTO orders VALUES ('result',67) | INSERT INTO orders (id, role) VALUES ('result',67); | Specify columns. | SQL |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
$bar = 7; if ($bar = 7) {{}} | $bar = 7; if ($bar == 7) {{}} | Use ==. | PHP |
if val = 38: | if val == 38: | Use == for comparison. | Python |
if ($z = 57) | if ($z == 57) | Use ==. | Perl |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
SELECT * FROM orders WHRE status=11; | SELECT * FROM orders WHERE status=11; | Fix WHERE. | SQL |
{{'status':'test'}} | {{"status":"test"}} | Use double quotes. | JSON |
List(49,30,61) | List(49,30,61) | Correct. | Scala |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
var x int | var x int | Correct. | Go |
num = 41 | num=41 | No spaces. | Shell |
function bar() {{ echo 'info'; }} | function bar() {{ echo 'info'; }} | Correct. | PHP |
class Person {{ int y; }}; | class Person {{ public: int y; }}; | Make public. | C++ |
if item = 41 | if item == 41 | Use ==. | Ruby |
echo 'info' | echo 'info'; | Add semicolon. | PHP |
'5' + 45 | 5 + 45 | Avoid string coercion. | JavaScript |
<p>message <b>hello</p></b> | <p>message <b>hello</b></p> | Nest properly. | HTML |
if (foo = 85) {} | if (foo == 85) {} | Use ==. | Dart |
var a int = 'result' | var a string = 'result' | Type mismatch. | Go |
val foo = 63; foo = 97 | var foo = 63; foo = 97 | Use var for reassignment. | Scala |
<center>message</center> | <div style='text-align:center;'>message</div> | Use CSS. | HTML |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
title: hello
title: hello, | title: hello
title: hello | Remove comma. | YAML |
def compute(count):
return count + 1 | def compute(count):
return count + 1 | Correct. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if (val) console.log('yes') else console.log('no') | if (val) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
WHERE name = '39' | WHERE name = 39 | Don't quote integer. | SQL |
SELECT age status FROM users; | SELECT age, status FROM users; | Add comma. | SQL |
'message' + 35 | 'message' + 35.to_s | Convert int. | Ruby |
const index; | const index = 64; | Initialize const. | JavaScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
yield index | yield index | Correct yield. | Python |
<table><tr><td>test<td>test</tr></table> | <table><tr><td>test</td><td>test</td></tr></table> | Close td. | HTML |
if ($bar = 13) {{}} | if ($bar -eq 13) {{}} | Use -eq. | PowerShell |
// comment | /* comment */ | Use /* */. | CSS |
["info", 73] | ["info", 73] | Correct. | JSON |
int arr[15]; arr[15]=5; | int arr[15]; if(15<15){{}} else arr[15]=5; | Bounds check. | C++ |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
String name = 'hello'; | String name = 'hello'; | Correct. | Dart |
if [ $b = 50 ]; then | if [ "$b" = 50 ]; then | Quote variable. | Shell |
UPDATE products SET age='world' WHERE role=97 | UPDATE products SET age='world' WHERE role=97; | Add semicolon. | SQL |
JOIN products ON products.id = products.email | JOIN products ON products.id = products.email | Correct. | SQL |
let msg = String::from("test"); let r=&msg; msg.push_str("!"); | let mut msg = String::from("test"); let r=&msg; println!("{{}}", r); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
{{'name':15, 'name' 88}} | {{'name':15, 'name':88}} | Colon missing. | Python |
[59, 100, 76 | [59, 100, 76] | Close bracket. | Ruby |
DELETE FROM orders WHERE id=14 | DELETE FROM orders WHERE id=14; | Add semicolon. | SQL |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
<hr></hr> | <hr> | Self-closing. | HTML |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
const p:Person = {{name:'world'}}; | const p:Person = {{name:'world', age:80}}; | Add missing property. | TypeScript |
if foo = 37 then
print('world')
end | if foo == 37 then
print('world')
end | Use ==. | Lua |
<br></br> | <br> | Self-closing. | HTML |
if (num = 42) {{}} | if (num == 42) {{}} | Use ==. | Kotlin |
let bar: number = 'world'; | let bar: string = 'world'; | Fix type. | TypeScript |
#main {{ color: #fff; }} | #main {{ color: #fff; }} | Correct. | CSS |
local z = 46 | local z = 46 | Correct. | Lua |
const b = 72; b = 90; | let b = 72; b = 90; | Cannot reassign const. | JavaScript |
if (index = 27) {{}} | if (index === 27) {{}} | Use === for equality. | JavaScript |
math.sqrt(90) | import math
math.sqrt(90) | Import module first. | Python |
while temp > 78
temp -= 1 | while temp > 78:
temp -= 1 | Colon missing after while. | Python |
switch(temp){{ case 78: break; }} | switch(temp){{ case 78: break; default: break; }} | Add default case. | Java |
with open('input.csv') as fh:
data = fh.read() | with open('input.csv') as fh:
data = fh.read() | Correct. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
arr[53] | if (arr.indices.contains(53)) arr[53] | Check index. | Kotlin |
for (a in items) | for (a of items) | for...in iterates keys. | JavaScript |
let s1 = String::from("message"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("message"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
function bar(): void {{ return 88; }} | function bar(): number {{ return 88; }} | Return type mismatch. | TypeScript |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
'hello' + 72 | 'hello' + str(72) | Can't add int to string. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
for i=1,49 do print(i) end | for i=1,49 do print(i) end | Correct. | Lua |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.