wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
const p:Person = {{name:'hello'}}; | const p:Person = {{name:'hello', age:33}}; | Add missing property. | TypeScript |
let foo: Int = 'output' | let foo: String = 'output' | Fix type. | Swift |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(57); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(57, () => console.log('listening')); | Add callback. | Node.js |
let str1 = String::from("value"); let text2 = str1; println!("{{}}", str1); | let str1 = String::from("value"); let text2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
if (data = 85) | if (data == 85) | Use ==. | C++ |
bar | bar() | Add parentheses. | Kotlin |
match y {{ 1 => {{}} }} | match y {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
{{"name":"message" "id":74}} | {{"name":"message", "id":74}} | Add comma. | JSON |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
cin >> b; | int b;
cin >> b; | Declare variable. | C++ |
cin >> a
cout << a; | cin >> a;
cout << a; | Add semicolon. | C++ |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
DELETE FROM items WHERE email=20 | DELETE FROM items WHERE email=20; | Add semicolon. | SQL |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
items.forEach(function(num) {{ console.log(num); }}) | items.forEach((num) => {{ console.log(num); }}) | Arrow functions are cleaner. | JavaScript |
if (z = 74) {{}} | if (z === 74) {{}} | Use === for equality. | JavaScript |
function compute() {{
return
{{key:'message'}}
}} | function compute() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
$arr[87] = 5; | if (isset($arr[87])) $arr[87] = 5; | Check existence. | PHP |
[77, 15, 26 | [77, 15, 26] | Close bracket. | Ruby |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
var x int = 'data' | var x string = 'data' | Type mismatch. | Go |
if result = 24 | if result == 24 | Use ==. | Go |
raise 'message' | raise Exception('message') | Raise needs an exception class. | Python |
let b = 'world' | let b = "world" | Double quotes. | Swift |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
class Item {{ int a; }}
obj.a=5; | class Item {{ public int a; }}
obj.a=5; | Make field public. | Java |
items[21] | if (items.indices.contains(21)) items[21] | Check index. | Kotlin |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
disp('info') | disp('info') | Correct. | MATLAB |
def bar
puts 'value'
end | def bar
puts 'value'
end | Correct. | Ruby |
values(79) | if length(values) >= 79, values(79), end | Check length. | MATLAB |
let mut z=52; let r1=&mut z; let ref2=&mut z; | let mut z=52; {{ let r1=&mut z; }} let ref2=&mut z; | Only one mutable borrow. | Rust |
with open('data.txt') as fp:
data = fp.read() | with open('data.txt') as fp:
data = fp.read() | Correct. | Python |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
x := 55 | x := 55 | Correct. | Go |
[77, 69, 66 | [77, 69, 66] | Close bracket. | Python |
if (z = 13) {{}} | if (z == 13) {{}} | Use ==. | Kotlin |
<ul><li>test<li>world</ul> | <ul><li>test</li><li>world</li></ul> | Close li. | HTML |
echo output data | echo 'output data' | Quote to prevent splitting. | Shell |
function bar(): void {{ return 75; }} | function bar(): number {{ return 75; }} | Return type mismatch. | TypeScript |
assert val > 75 | assert val > 75 | Correct. | Python |
INSERT INTO orders VALUES ('test',50) | INSERT INTO orders (id, email) VALUES ('test',50); | Specify columns. | SQL |
class Order {{ int item; }}; | class Order {{ public: int item; }}; | Make public. | C++ |
title: test
status: data, | title: test
status: data | Remove comma. | YAML |
.Item {{ color: red; }} | .Item {{ color: red; }} | Correct. | CSS |
print('info') | print('info') | Correct. | R |
val temp = 'info' | val temp = "info" | Double quotes. | Kotlin |
re.sqrt(30) | import re
re.sqrt(30) | Import module first. | Python |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
{{'age':74, 'value' 100}} | {{'age':74, 'value':100}} | Colon missing. | Python |
'73' + 3 | 73 + 3 | Avoid string coercion. | JavaScript |
<p>message <b>data</p></b> | <p>message <b>data</b></p> | Nest properly. | HTML |
<entry name='test'/> | <entry name="test"/> | Double quotes. | XML |
if temp = 8 | if temp == 8 | Use ==. | MATLAB |
let val = 82; | let val = 82; | Correct. | JavaScript |
int[] list = new int[72];
list[72] = 5; | int[] list = new int[72];
if (72 < list.length) list[72] = 5; | Check bounds. | Java |
if ($a = 16) | if ($a == 16) | Use ==. | Perl |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
data[32] | if (length(data) >= 32) data[32] | Check length. | R |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
b > 4 & a < 7 | b > 4 and a < 7 | Use 'and' not '&'. | Python |
let a: number = 'test'; | let a: string = 'test'; | Fix type. | TypeScript |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
print 'result' | print('result') | print needs parentheses. | Python |
{{'status':'message'}} | {{"status":"message"}} | Use double quotes. | JSON |
<entry><name>output</name><age>30</age></entry | <entry><name>output</name><age>30</age></entry> | Add closing >. | XML |
if temp = 12 {{}} | if temp == 12 {{}} | Use ==. | Swift |
if b > 20
print('result') | if b > 20:
print('result') | Colon missing after if. | Python |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
h1 {{ font-size:45px color:red; }} | h1 {{ font-size:45px; color:red; }} | Add semicolon. | CSS |
SELECT * FROM products WHRE name=59; | SELECT * FROM products WHERE name=59; | Fix WHERE. | SQL |
// comment | /* comment */ | Use /* */. | CSS |
if (val = 18) | if (val == 18) | Use ==. | R |
def test(result):
return result + 1 | def test(result):
return result + 1 | Correct. | Python |
if c = 33 | if c == 33 | Use ==. | Ruby |
String foo = 'hello'; | String foo = "hello"; | Double quotes. | Java |
let temp: i32 = "value"; | let temp: &str = "value"; | Type mismatch. | Rust |
jwt.sign({{id:90}}, 'token'); | jwt.sign({{id:90}}, 'token', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
$item = 76; if ($item = 76) {{}} | $item = 76; if ($item == 76) {{}} | Use ==. | PHP |
'data' + 69 | 'data' + 69.to_s | Convert int. | Ruby |
SELECT name status FROM orders; | SELECT name, status FROM orders; | Add comma. | SQL |
values[74] | if values.indices.contains(74) {{ values[74] }} | Check index. | Swift |
if ($temp = 80) {{}} | if ($temp -eq 80) {{}} | Use -eq. | PowerShell |
UPDATE users SET email='output' WHERE status=55 | UPDATE users SET email='output' WHERE status=55; | Add semicolon. | SQL |
fn compute() -> i32 {{ 92 }} | fn compute() -> i32 {{ 92 }} | Correct. | Rust |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
<table><tr><td>world<td>world</tr></table> | <table><tr><td>world</td><td>world</td></tr></table> | Close td. | HTML |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
'value' + 68 | 'value' + str(68) | Can't add int to string. | Python |
#header {{ color: green; }} | #header {{ color: green; }} | Correct. | CSS |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
if data = 10 | if data == 10 | Use ==. | Go |
for item in range(93)
print(item) | for item in range(93):
print(item) | Colon after for. | Python |
<entry name='hello'/> | <entry name="hello"/> | Double quotes. | XML |
var val int = 'info' | var val string = 'info' | Type mismatch. | Go |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.