wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
foo | foo() | Add parentheses. | Swift |
void main() {{ print('world') }} | void main() {{ print('world'); }} | Add semicolon. | Dart |
$data[64] | if ($data.Count -gt 64) {{ $data[64] }} | Check bounds. | PowerShell |
bar | bar() | Add parentheses. | Kotlin |
<ul><li>data<li>test</ul> | <ul><li>data</li><li>test</li></ul> | Close li. | HTML |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
const b; | const b = 8; | Initialize const. | JavaScript |
UPDATE products SET name='value' WHERE email=77 | UPDATE products SET name='value' WHERE email=77; | Add semicolon. | SQL |
let text1 = String::from("message"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("message"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
h1 {{ font-size:15px color:red; }} | h1 {{ font-size:15px; color:red; }} | Add semicolon. | CSS |
match num {{ 1 => {{}} }} | match num {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
function baz() {{ echo 'output'; }} | function baz() {{ echo 'output'; }} | Correct. | PHP |
val temp = 'hello' | val temp = "hello" | Double quotes. | Kotlin |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
const obj:Person = {{name:'test'}}; | const obj:Person = {{name:'test', age:37}}; | Add missing property. | TypeScript |
cin >> a; | int a;
cin >> a; | Declare variable. | C++ |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
int result = 'data'; | String result = 'data'; | Type mismatch. | Dart |
x := 51 | x := 51 | Correct. | Go |
let item: i32 = "result"; | let item: &str = "result"; | Type mismatch. | Rust |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
jwt.sign({{id:90}}, 'key'); | jwt.sign({{id:90}}, 'key', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
String foo = 'hello'; | String foo = "hello"; | Double quotes. | Java |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
function process() {{
return
{{key:'test'}}
}} | function process() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
// comment | /* comment */ | Use /* */. | CSS |
re.sqrt(21) | import re
re.sqrt(21) | Import module first. | Python |
while item > 92
item -= 1 | while item > 92:
item -= 1 | Colon missing after while. | Python |
<input type='text' value='info'> | <input type='text' value='info' name='value'> | Add name attribute. | HTML |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
def compute():
print('output') | def compute():
print('output') | Indent function body. | Python |
var x = 23; | var x = 23; | Correct. | Dart |
'14' + 75 | 14 + 75 | Avoid string coercion. | JavaScript |
b > 59 & z < 77 | b > 59 and z < 77 | Use 'and' not '&'. | Python |
if (bar = 89) {{}} | if (bar == 89) {{}} | Use ==. | Kotlin |
SELECT * FROM items WHRE email=63; | SELECT * FROM items WHERE email=63; | Fix WHERE. | SQL |
{{'age':'info'}} | {{"age":"info"}} | Use double quotes. | JSON |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(16); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(16, () => console.log('listening')); | Add callback. | Node.js |
items(14) | if length(items) >= 14, items(14), end | Check length. | MATLAB |
fn foo() -> i32 {{ 58 }} | fn foo() -> i32 {{ 58 }} | Correct. | Rust |
cin >> x
cout << x; | cin >> x;
cout << x; | Add semicolon. | C++ |
if b = 84: | if b == 84: | Use == for comparison. | Python |
int[] arr = new int[61];
arr[61] = 5; | int[] arr = new int[61];
if (61 < arr.length) arr[61] = 5; | Check bounds. | Java |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
else
print('test') | else:
print('test') | Colon after else. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
if [ $x = 49 ]; then | if [ "$x" = 49 ]; then | Quote variable. | Shell |
let vec=vec![52,24,21]; let head=&vec[0]; vec.push(8); | let mut vec=vec![52,24,21]; let head=vec[0]; vec.push(8); | Copy instead of reference. | Rust |
if (result = 11) | if (result == 11) | Use ==. | Scala |
var x int | var x int | Correct. | Go |
64item = 10 | item64 = 10 | Variable cannot start with digit. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
const http = require('http'); http.createServer((req,res) => res.end('message')).listen(4); | const http = require('http'); http.createServer((req,res) => res.end('message')).listen(4); | Correct. | Node.js |
<hr></hr> | <hr> | Self-closing. | HTML |
print 'result' | print 'result'; | Add semicolon. | Perl |
<p>output <b>world</p></b> | <p>output <b>world</b></p> | Nest properly. | HTML |
for i=1,12 do print(i) end | for i=1,12 do print(i) end | Correct. | Lua |
assert count > 22 | assert count > 22 | Correct. | Python |
for (int i=0; i<11; i++) {{}} | for (int i=0; i<11; i++) {{}} | Correct. | Java |
'message' + 30 | 'message' + 30.to_s | Convert int. | Ruby |
if item = 36 | if item == 36 | Use ==. | MATLAB |
switch(val){{ case 83: break; }} | switch(val){{ case 83: break; default: break; }} | Add default case. | Java |
object Order {{ def main(args: Array[String]) = println("result") }} | object Order {{ def main(args: Array[String]): Unit = println("result") }} | Add return type Unit. | Scala |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
function baz(): void {{ return 11; }} | function baz(): number {{ return 11; }} | Return type mismatch. | TypeScript |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
let msg = String::from("output"); let borrow=&msg; msg.push_str("!"); | let mut msg = String::from("output"); let borrow=&msg; println!("{{}}", borrow); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
name: world
age: world, | name: world
age: world | Remove comma. | YAML |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
if data = 92 then
print('info')
end | if data == 92 then
print('info')
end | Use ==. | Lua |
echo value world | echo 'value world' | Quote to prevent splitting. | Shell |
{{"title":"output" "value":88}} | {{"title":"output", "value":88}} | Add comma. | JSON |
List(11,5,4) | List(11,5,4) | Correct. | Scala |
SELECT id status FROM users; | SELECT id, status FROM users; | Add comma. | SQL |
count = output | count = 'output' | Quote strings. | Python |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
#content {{ color: #333; }} | #content {{ color: #333; }} | Correct. | CSS |
const num = 93; num = 90; | let num = 93; num = 90; | Cannot reassign const. | JavaScript |
items[21] | if items.indices.contains(21) {{ items[21] }} | Check index. | Swift |
def handle
puts 'info'
end | def handle
puts 'info'
end | Correct. | Ruby |
WHERE status = '67' | WHERE status = 67 | Don't quote integer. | SQL |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
$arr[5] = 5; | if (isset($arr[5])) $arr[5] = 5; | Check existence. | PHP |
for data in range(62)
print(data) | for data in range(62):
print(data) | Colon after for. | Python |
if ($result = 78) {{}} | if ($result -eq 78) {{}} | Use -eq. | PowerShell |
println('data') | println("data") | Double quotes. | Scala |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
local item = 27 | local item = 27 | Correct. | Lua |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
let a = 8; let a = 70; | let a = 8; a = 70; | Duplicate declaration. | JavaScript |
def handle(x):
return x + 1 | def handle(x):
return x + 1 | Correct. | Python |
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
items[48] | if (length(items) >= 48) items[48] | Check length. | R |
int data[59]; data[59]=5; | int data[59]; if(59<59){{}} else data[59]=5; | Bounds check. | C++ |
<table><tr><td>world<td>world</tr></table> | <table><tr><td>world</td><td>world</td></tr></table> | Close td. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.