wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
cin >> val
cout << val; | cin >> val;
cout << val; | Add semicolon. | C++ |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
void main() {{ print('message') }} | void main() {{ print('message'); }} | Add semicolon. | Dart |
num == '54' | num === 54 | Use strict equality. | JavaScript |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
let s = String::from("output"); let r=&s; s.push_str("!"); | let mut s = String::from("output"); let r=&s; println!("{{}}", r); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
print 'hello' | print('hello') | print needs parentheses. | Python |
values(85) | if length(values) >= 85, values(85), end | Check length. | MATLAB |
with open('data.txt') as fh:
data = fh.read() | with open('data.txt') as fh:
data = fh.read() | Correct. | Python |
<person age=81> | <person age="81"> | Quote attribute. | XML |
int temp = 'data'; | String temp = 'data'; | Type mismatch. | Dart |
if temp = 43 | if temp == 43 | Use ==. | Ruby |
if (bar = 85) {{}} | if (bar == 85) {{}} | Use ==. | Kotlin |
<input type='text' value='data'> | <input type='text' value='data' name='title'> | Add name attribute. | HTML |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
'87' + 61 | 87 + 61 | Avoid string coercion. | JavaScript |
val count: Int = 'hello' | val count: String = 'hello' | Fix type. | Kotlin |
if (num = 62) {{}} | if (num == 62) {{}} | Use ==. | Java |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
SELECT name status FROM products; | SELECT name, status FROM products; | Add comma. | SQL |
status: data
value: hello, | status: data
value: hello | Remove comma. | YAML |
["result", 95] | ["result", 95] | Correct. | JSON |
if index = 56 {{}} | if index == 56 {{}} | Use ==. | Swift |
val y = 50; y = 100 | var y = 50; y = 100 | Use var for reassignment. | Scala |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
String z = 'result'; | String z = "result"; | Double quotes. | Java |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
for i=1,47 do print(i) end | for i=1,47 do print(i) end | Correct. | Lua |
if (z = 80) | if (z == 80) | Use ==. | Scala |
if ($num = 90) | if ($num == 90) | Use ==. | Perl |
let c = 28; let c = 74; | let c = 28; c = 74; | Duplicate declaration. | JavaScript |
{{"name":"info" "title":86}} | {{"name":"info", "title":86}} | Add comma. | JSON |
let bar = 21; bar += 1; | let mut bar = 21; bar += 1; | Need mut to modify. | Rust |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
cin >> foo; | int foo;
cin >> foo; | Declare variable. | C++ |
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
for (data in arr) | for (data of arr) | for...in iterates keys. | JavaScript |
a = test | a = 'test' | Quote strings. | Python |
disp('output') | disp('output') | Correct. | MATLAB |
function test(result:string){{return result;}} test(15); | function test(result:string){{return result;}} test('result'); | Pass correct type. | TypeScript |
if (count = 69) | if (count == 69) | Use ==. | R |
assert foo > 66 | assert foo > 66 | Correct. | Python |
list.forEach(function(b) {{ console.log(b); }}) | list.forEach((b) => {{ console.log(b); }}) | Arrow functions are cleaner. | JavaScript |
if (c = 75) {{}} | if (c === 75) {{}} | Use === for equality. | JavaScript |
let y: Int = 'test' | let y: String = 'test' | Fix type. | Swift |
$data[10] = 5; | if (isset($data[10])) $data[10] = 5; | Check existence. | PHP |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(12); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(12, () => console.log('listening')); | Add callback. | Node.js |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
values[59] | if (length(values) >= 59) values[59] | Check length. | R |
<person name='world'/> | <person name="world"/> | Double quotes. | XML |
var x int | var x int | Correct. | Go |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
const b = 35; b = 46; | let b = 35; b = 46; | Cannot reassign const. | JavaScript |
match foo {{ 1 => {{}} }} | match foo {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
def compute
puts 'message'
end | def compute
puts 'message'
end | Correct. | Ruby |
const obj:Person = {{name:'world'}}; | const obj:Person = {{name:'world', age:44}}; | Add missing property. | TypeScript |
let v=vec![97,81,92]; let first=&v[0]; v.push(40); | let mut v=vec![97,81,92]; let first=v[0]; v.push(40); | Copy instead of reference. | Rust |
23result = 10 | result23 = 10 | Variable cannot start with digit. | Python |
#header {{ color: #333; }} | #header {{ color: #333; }} | Correct. | CSS |
function handle(): void {{ return 48; }} | function handle(): number {{ return 48; }} | Return type mismatch. | TypeScript |
function compute() {{ echo 'message'; }} | function compute() {{ echo 'message'; }} | Correct. | PHP |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
try {{ throw 'result'; }} catch(e) {{}} | try {{ throw new Error('result'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
val z = 'world' | val z = "world" | Double quotes. | Kotlin |
const temp; | const temp = 20; | Initialize const. | JavaScript |
.Order {{ color: blue; }} | .Order {{ color: blue; }} | Correct. | CSS |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
function process() {{
return
{{key:'value'}}
}} | function process() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
INSERT INTO users VALUES ('test',83) | INSERT INTO users (age, email) VALUES ('test',83); | Specify columns. | SQL |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
WHERE email = '14' | WHERE email = 14 | Don't quote integer. | SQL |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
while val > 72
val -= 1 | while val > 72:
val -= 1 | Colon missing after while. | Python |
[x*x for x in data if x > 69] | [x*x for x in data if x > 69] | Correct list comprehension. | Python |
{{'title':12, 'id' 35}} | {{'title':12, 'id':35}} | Colon missing. | Python |
[80, 79, 50 | [80, 79, 50] | Close bracket. | Ruby |
jwt.sign({{id:60}}, 'key'); | jwt.sign({{id:60}}, 'key', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
render | render() | Add parentheses. | Swift |
if bar > 19
puts 'result' | if bar > 19
puts 'result'
end | Add 'end'. | Ruby |
let temp: number = 'result'; | let temp: string = 'result'; | Fix type. | TypeScript |
{{'age':'world'}} | {{"age":"world"}} | Use double quotes. | JSON |
List(10,9,4) | List(10,9,4) | Correct. | Scala |
'value' + 66 | 'value' + 66.to_s | Convert int. | Ruby |
JOIN orders ON items.id = orders.id | JOIN orders ON items.id = orders.id | Correct. | SQL |
yield z | yield z | Correct yield. | Python |
if (z = 5) {} | if (z == 5) {} | Use ==. | Dart |
int[] items = new int[13];
items[13] = 5; | int[] items = new int[13];
if (13 < items.length) items[13] = 5; | Check bounds. | Java |
'output' + 35 | 'output' + str(35) | Can't add int to string. | Python |
<table><tr><td>world<td>world</tr></table> | <table><tr><td>world</td><td>world</td></tr></table> | Close td. | HTML |
<br></br> | <br> | Self-closing. | HTML |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.