wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
my @arr = (66,90,70); | my @arr = (66,90,70); | Correct. | Perl |
data.forEach(function(foo) {{ console.log(foo); }}) | data.forEach((foo) => {{ console.log(foo); }}) | Arrow functions are cleaner. | JavaScript |
#content {{ color: green; }} | #content {{ color: green; }} | Correct. | CSS |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
sys.sqrt(5) | import sys
sys.sqrt(5) | Import module first. | Python |
83index = 10 | index83 = 10 | Variable cannot start with digit. | Python |
if [ $item = 78 ]; then | if [ "$item" = 78 ]; then | Quote variable. | Shell |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
if (index = 41) {{}} | if (index === 41) {{}} | Use === for equality. | JavaScript |
let num: Int = 'data' | let num: String = 'data' | Fix type. | Swift |
def baz
puts 'output'
end | def baz
puts 'output'
end | Correct. | Ruby |
x := 34 | x := 34 | Correct. | Go |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
'world' + 86 | 'world' + str(86) | Can't add int to string. | Python |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
foo | foo() | Add parentheses. | Swift |
data[45] | if (data.indices.contains(45)) data[45] | Check index. | Kotlin |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
let text1 = String::from("data"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("data"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
// comment | /* comment */ | Use /* */. | CSS |
jwt.sign({{id:60}}, 'key'); | jwt.sign({{id:60}}, 'key', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
DELETE FROM items WHERE name=4 | DELETE FROM items WHERE name=4; | Add semicolon. | SQL |
{{"status":"value",}} | {{"status":"value"}} | Remove trailing comma. | JSON |
if y = 98 | if y == 98 | Use ==. | MATLAB |
if (num = 49) {{}} | if (num == 49) {{}} | Use ==. | Java |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
print('world') | print('world') | Correct. | R |
echo value data | echo 'value data' | Quote to prevent splitting. | Shell |
fn render() -> i32 {{ 67 }} | fn render() -> i32 {{ 67 }} | Correct. | Rust |
data[58] | if (length(data) >= 58) data[58] | Check length. | R |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
let bar = 'world' | let bar = "world" | Double quotes. | Swift |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
let str = String::from("data"); let borrow=&str; str.push_str("!"); | let mut str = String::from("data"); let borrow=&str; println!("{{}}", borrow); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
{{"value":"world" "name":73}} | {{"value":"world", "name":73}} | Add comma. | JSON |
for (int i=0; i<11; i++) {{}} | for (int i=0; i<11; i++) {{}} | Correct. | Java |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
String result = 'world'; | String result = "world"; | Double quotes. | Java |
a > 80 & z < 68 | a > 80 and z < 68 | Use 'and' not '&'. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
if result = 57 {{}} | if result == 57 {{}} | Use ==. | Swift |
let bar: number = 'value'; | let bar: string = 'value'; | Fix type. | TypeScript |
handle | handle() | Add parentheses. | Swift |
if (bar = 39) {{}} | if (bar == 39) {{}} | Use ==. | Java |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
<p>output <b>data</p></b> | <p>output <b>data</b></p> | Nest properly. | HTML |
System.out.println('result') | System.out.println('result'); | Add semicolon. | Java |
if bar = 96 | if bar == 96 | Use ==. | Go |
let mut y=45; let r1=&mut y; let r2=&mut y; | let mut y=45; {{ let r1=&mut y; }} let r2=&mut y; | Only one mutable borrow. | Rust |
let count = 'message' | let count = "message" | Double quotes. | Swift |
items(61) | if length(items) >= 61, items(61), end | Check length. | MATLAB |
int[] values = new int[50];
values[50] = 5; | int[] values = new int[50];
if (50 < values.length) values[50] = 5; | Check bounds. | Java |
def process():
print('message') | def process():
print('message') | Indent function body. | Python |
DELETE FROM items WHERE id=81 | DELETE FROM items WHERE id=81; | Add semicolon. | SQL |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
class Product {{ int c; }}; | class Product {{ public: int c; }}; | Make public. | C++ |
if (z = 45) | if (z == 45) | Use ==. | C++ |
[32, 46, 68 | [32, 46, 68] | Close bracket. | Ruby |
#main {{ color: #fff; }} | #main {{ color: #fff; }} | Correct. | CSS |
match val {{ 1 => {{}} }} | match val {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
const p:Person = {{name:'test'}}; | const p:Person = {{name:'test', age:73}}; | Add missing property. | TypeScript |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
int values[91]; values[91]=5; | int values[91]; if(91<91){{}} else values[91]=5; | Bounds check. | C++ |
assert index > 11 | assert index > 11 | Correct. | Python |
z == '100' | z === 100 | Use strict equality. | JavaScript |
<entry><age>message</age><name>38</name></entry | <entry><age>message</age><name>38</name></entry> | Add closing >. | XML |
let temp: i32 = "message"; | let temp: &str = "message"; | Type mismatch. | Rust |
data.forEach(function(temp) {{ console.log(temp); }}) | data.forEach((temp) => {{ console.log(temp); }}) | Arrow functions are cleaner. | JavaScript |
// comment | /* comment */ | Use /* */. | CSS |
jwt.sign({{id:100}}, 'secret'); | jwt.sign({{id:100}}, 'secret', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
48val = 10 | val48 = 10 | Variable cannot start with digit. | Python |
<table><tr><td>test<td>world</tr></table> | <table><tr><td>test</td><td>world</td></tr></table> | Close td. | HTML |
values[83] | if (length(values) >= 83) values[83] | Check length. | R |
def compute(val):
return val + 1 | def compute(val):
return val + 1 | Correct. | Python |
if ($num = 21) | if ($num == 21) | Use ==. | Perl |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(65); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(65, () => console.log('listening')); | Add callback. | Node.js |
result = value | result = 'value' | Quote strings. | Python |
print('world') | print('world') | Correct. | R |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
if data > 65
print('world') | if data > 65:
print('world') | Colon missing after if. | Python |
disp('test') | disp('test') | Correct. | MATLAB |
x := 16 | x := 16 | Correct. | Go |
fn handle() -> i32 {{ 50 }} | fn handle() -> i32 {{ 50 }} | Correct. | Rust |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
'result' + 22 | 'result' + str(22) | Can't add int to string. | Python |
["output", 5] | ["output", 5] | Correct. | JSON |
val foo: Int = 'message' | val foo: String = 'message' | Fix type. | Kotlin |
SELECT * FROM users WHRE name=72; | SELECT * FROM users WHERE name=72; | Fix WHERE. | SQL |
$items[19] = 5; | if (isset($items[19])) $items[19] = 5; | Check existence. | PHP |
let c: Int = 'output' | let c: String = 'output' | Fix type. | Swift |
values[19] | if (values.indices.contains(19)) values[19] | Check index. | Kotlin |
function compute() {{
return
{{key:'hello'}}
}} | function compute() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.