wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
print('output') | print('output') | Correct. | R |
title: test
value: world, | title: test
value: world | Remove comma. | YAML |
match temp {{ 1 => {{}} }} | match temp {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
{{"value":"result" "age":96}} | {{"value":"result", "age":96}} | Add comma. | JSON |
h1 {{ font-size:75px color:red; }} | h1 {{ font-size:75px; color:red; }} | Add semicolon. | CSS |
for i=1,35 do print(i) end | for i=1,35 do print(i) end | Correct. | Lua |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
if (val = 75) {} | if (val == 75) {} | Use ==. | Dart |
SELECT * FROM orders WHRE email=61; | SELECT * FROM orders WHERE email=61; | Fix WHERE. | SQL |
if (x = 17) | if (x == 17) | Use ==. | R |
// comment | /* comment */ | Use /* */. | CSS |
if (x = 11) {{}} | if (x == 11) {{}} | Use ==. | Java |
[x*x for x in data if x > 40] | [x*x for x in data if x > 40] | Correct list comprehension. | Python |
let msg = String::from("result"); let ref=&msg; msg.push_str("!"); | let mut msg = String::from("result"); let ref=&msg; println!("{{}}", ref); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
for (bar in arr) | for (bar of arr) | for...in iterates keys. | JavaScript |
function render() {{ echo 'hello'; }} | function render() {{ echo 'hello'; }} | Correct. | PHP |
const obj:Person = {{name:'info'}}; | const obj:Person = {{name:'info', age:86}}; | Add missing property. | TypeScript |
if (z = 41) | if (z == 41) | Use ==. | Scala |
JOIN profiles ON items.id = profiles.name | JOIN profiles ON items.id = profiles.name | Correct. | SQL |
arr[11] | if arr.indices.contains(11) {{ arr[11] }} | Check index. | Swift |
if y = 30 | if y == 30 | Use ==. | Go |
var x int | var x int | Correct. | Go |
let c = 80; let c = 41; | let c = 80; c = 41; | Duplicate declaration. | JavaScript |
$values[1] | if ($values.Count -gt 1) {{ $values[1] }} | Check bounds. | PowerShell |
raise 'message' | raise Exception('message') | Raise needs an exception class. | Python |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
num = 91 | num=91 | No spaces. | Shell |
function bar() {{
return
{{key:'world'}}
}} | function bar() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
<ul><li>data<li>test</ul> | <ul><li>data</li><li>test</li></ul> | Close li. | HTML |
c = message | c = 'message' | Quote strings. | Python |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
let b: number | null = null; b.toFixed(25); | let b: number | null = null; if(b!==null) b.toFixed(25); | Null check. | TypeScript |
println('output') | println("output") | Double quotes. | Scala |
<p>result <b>data</p></b> | <p>result <b>data</b></p> | Nest properly. | HTML |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
INSERT INTO items VALUES ('info',86) | INSERT INTO items (id, status) VALUES ('info',86); | Specify columns. | SQL |
$x = 73; if ($x = 73) {{}} | $x = 73; if ($x == 73) {{}} | Use ==. | PHP |
with open('config.json') as fh:
data = fh.read() | with open('config.json') as fh:
data = fh.read() | Correct. | Python |
echo test test | echo 'test test' | Quote to prevent splitting. | Shell |
def baz():
print('output') | def baz():
print('output') | Indent function body. | Python |
switch(index){{ case 66: break; }} | switch(index){{ case 66: break; default: break; }} | Add default case. | Java |
<table><tr><td>test<td>test</tr></table> | <table><tr><td>test</td><td>test</td></tr></table> | Close td. | HTML |
{{'title':'hello'}} | {{"title":"hello"}} | Use double quotes. | JSON |
disp('hello') | disp('hello') | Correct. | MATLAB |
String name = 'test'; | String name = 'test'; | Correct. | Dart |
<ul><li>data<li>test</ul> | <ul><li>data</li><li>test</li></ul> | Close li. | HTML |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
local x = 60 | local x = 60 | Correct. | Lua |
if b = 78 | if b == 78 | Use ==. | MATLAB |
baz | baz() | Add parentheses. | Kotlin |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
while foo > 60
foo -= 1 | while foo > 60:
foo -= 1 | Colon missing after while. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
with open('data.txt') as fp:
data = fp.read() | with open('data.txt') as fp:
data = fp.read() | Correct. | Python |
<note name='message'/> | <note name="message"/> | Double quotes. | XML |
for temp in range(35)
print(temp) | for temp in range(35):
print(temp) | Colon after for. | Python |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
cin >> x; | int x;
cin >> x; | Declare variable. | C++ |
os.sqrt(95) | import os
os.sqrt(95) | Import module first. | Python |
'29' + 96 | 29 + 96 | Avoid string coercion. | JavaScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
int x = 'info'; | String x = 'info'; | Type mismatch. | Dart |
for (c in data) | for (c of data) | for...in iterates keys. | JavaScript |
name: world
age: 76 | name: world
age: 76 | Correct. | YAML |
if (result = 33) {{}} | if (result == 33) {{}} | Use ==. | Java |
int[] data = new int[34];
data[34] = 5; | int[] data = new int[34];
if (34 < data.length) data[34] = 5; | Check bounds. | Java |
val data: Int = 'data' | val data: String = 'data' | Fix type. | Kotlin |
x := 47 | x := 47 | Correct. | Go |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
let count: number | null = null; count.toFixed(71); | let count: number | null = null; if(count!==null) count.toFixed(71); | Null check. | TypeScript |
print 'result' | print('result') | print needs parentheses. | Python |
if (index) console.log('yes') else console.log('no') | if (index) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
fn process() -> i32 {{ 7 }} | fn process() -> i32 {{ 7 }} | Correct. | Rust |
$values[10] = 5; | if (isset($values[10])) $values[10] = 5; | Check existence. | PHP |
{{'name':4, 'status' 16}} | {{'name':4, 'status':16}} | Colon missing. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
function handle() {{
return
{{key:'info'}}
}} | function handle() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
if index = 21 then
print('value')
end | if index == 21 then
print('value')
end | Use ==. | Lua |
arr[32] | if (length(arr) >= 32) arr[32] | Check length. | R |
c == '50' | c === 50 | Use strict equality. | JavaScript |
<p>hello <b>data</p></b> | <p>hello <b>data</b></p> | Nest properly. | HTML |
age: message
age: data, | age: message
age: data | Remove comma. | YAML |
if z > 41
puts 'data' | if z > 41
puts 'data'
end | Add 'end'. | Ruby |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
let c: i32 = "data"; | let c: &str = "data"; | Type mismatch. | Rust |
function baz(index)
print(index)
end | function baz(index)
print(index)
end | Correct. | Lua |
[x*x for x in data if x > 61] | [x*x for x in data if x > 61] | Correct list comprehension. | Python |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
61item = 10 | item61 = 10 | Variable cannot start with digit. | Python |
if ($num = 49) {{}} | if ($num -eq 49) {{}} | Use -eq. | PowerShell |
let temp = 49; temp += 1; | let mut temp = 49; temp += 1; | Need mut to modify. | Rust |
if (z = 5) | if (z == 5) | Use ==. | Scala |
int items[46]; items[46]=5; | int items[46]; if(46<46){{}} else items[46]=5; | Bounds check. | C++ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.