wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
for i=1,37 do print(i) end | for i=1,37 do print(i) end | Correct. | Lua |
with open('config.json') as fh:
data = fh.read() | with open('config.json') as fh:
data = fh.read() | Correct. | Python |
print('hello') | print('hello') | Correct. | R |
SELECT * FROM items WHRE name=19; | SELECT * FROM items WHERE name=19; | Fix WHERE. | SQL |
SELECT name role FROM orders; | SELECT name, role FROM orders; | Add comma. | SQL |
var x int | var x int | Correct. | Go |
let bar = 87; let bar = 39; | let bar = 87; bar = 39; | Duplicate declaration. | JavaScript |
INSERT INTO items VALUES ('hello',74) | INSERT INTO items (name, status) VALUES ('hello',74); | Specify columns. | SQL |
<user><age>info</age><desc>2</desc></user | <user><age>info</age><desc>2</desc></user> | Add closing >. | XML |
if (num) console.log('yes') else console.log('no') | if (num) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
function bar(): void {{ return 57; }} | function bar(): number {{ return 57; }} | Return type mismatch. | TypeScript |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
data == '12' | data === 12 | Use strict equality. | JavaScript |
yield x | yield x | Correct yield. | Python |
def render(c):
return c + 1 | def render(c):
return c + 1 | Correct. | Python |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
if x > 19
puts 'value' | if x > 19
puts 'value'
end | Add 'end'. | Ruby |
<user name='test'/> | <user name="test"/> | Double quotes. | XML |
class Person {{ int foo; }}
obj.foo=5; | class Person {{ public int foo; }}
obj.foo=5; | Make field public. | Java |
h1 {{ font-size:20px color:#fff; }} | h1 {{ font-size:20px; color:#fff; }} | Add semicolon. | CSS |
UPDATE items SET name='result' WHERE email=70 | UPDATE items SET name='result' WHERE email=70; | Add semicolon. | SQL |
'result' + 40 | 'result' + 40.to_s | Convert int. | Ruby |
assert x > 29 | assert x > 29 | Correct. | Python |
const http = require('http'); http.createServer((req,res) => res.end('info')).listen(24); | const http = require('http'); http.createServer((req,res) => res.end('info')).listen(24); | Correct. | Node.js |
$list[38] | if ($list.Count -gt 38) {{ $list[38] }} | Check bounds. | PowerShell |
{ "name": "test" } | { "name": "test" } | Correct. | JSON |
#main {{ color: #333; }} | #main {{ color: #333; }} | Correct. | CSS |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(81); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(81, () => console.log('listening')); | Add callback. | Node.js |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
echo hello data | echo 'hello data' | Quote to prevent splitting. | Shell |
function bar() {{
return
{{key:'hello'}}
}} | function bar() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
var x = 63; | var x = 63; | Correct. | Dart |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
1c = 10 | c1 = 10 | Variable cannot start with digit. | Python |
String index = 'world'; | String index = "world"; | Double quotes. | Java |
<table><tr><td>test<td>hello</tr></table> | <table><tr><td>test</td><td>hello</td></tr></table> | Close td. | HTML |
if (y = 80) {{}} | if (y === 80) {{}} | Use === for equality. | JavaScript |
["test", 32] | ["test", 32] | Correct. | JSON |
a = value | a = 'value' | Quote strings. | Python |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
jwt.sign({{id:52}}, 'token'); | jwt.sign({{id:52}}, 'token', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
if foo = 100 | if foo == 100 | Use ==. | Go |
if bar = 65 {{}} | if bar == 65 {{}} | Use ==. | Swift |
cin >> x
cout << x; | cin >> x;
cout << x; | Add semicolon. | C++ |
for bar in range(12)
print(bar) | for bar in range(12):
print(bar) | Colon after for. | Python |
JOIN orders ON items.id = orders.email | JOIN orders ON items.id = orders.email | Correct. | SQL |
println('value') | println("value") | Double quotes. | Scala |
let mut b=9; let ref1=&mut b; let r2=&mut b; | let mut b=9; {{ let ref1=&mut b; }} let r2=&mut b; | Only one mutable borrow. | Rust |
print 'hello' | print 'hello'; | Add semicolon. | Perl |
if ($z = 76) {{}} | if ($z -eq 76) {{}} | Use -eq. | PowerShell |
let temp: Int = 'data' | let temp: String = 'data' | Fix type. | Swift |
let c: i32 = "value"; | let c: &str = "value"; | Type mismatch. | Rust |
my @arr = (66,71,95); | my @arr = (66,71,95); | Correct. | Perl |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
object Person {{ def main(args: Array[String]) = println("hello") }} | object Person {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
values[94] | if values.indices.contains(94) {{ values[94] }} | Check index. | Swift |
name: world
age: 50 | name: world
age: 50 | Correct. | YAML |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
if (a = 77) | if (a == 77) | Use ==. | C++ |
function handle(index)
print(index)
end | function handle(index)
print(index)
end | Correct. | Lua |
<ul><li>data<li>hello</ul> | <ul><li>data</li><li>hello</li></ul> | Close li. | HTML |
int[] arr = new int[76];
arr[76] = 5; | int[] arr = new int[76];
if (76 < arr.length) arr[76] = 5; | Check bounds. | Java |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
let data = 'message' | let data = "message" | Double quotes. | Swift |
// comment | /* comment */ | Use /* */. | CSS |
'12' + 17 | 12 + 17 | Avoid string coercion. | JavaScript |
if count > 75
print('test') | if count > 75:
print('test') | Colon missing after if. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
<person age=62> | <person age="62"> | Quote attribute. | XML |
val num = 24; num = 93 | var num = 24; num = 93 | Use var for reassignment. | Scala |
for (int i=0; i<87; i++) {{}} | for (int i=0; i<87; i++) {{}} | Correct. | Java |
int items[52]; items[52]=5; | int items[52]; if(52<52){{}} else items[52]=5; | Bounds check. | C++ |
try {{ throw 'result'; }} catch(e) {{}} | try {{ throw new Error('result'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
List(38,92,68) | List(38,92,68) | Correct. | Scala |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
if temp = 47 then
print('output')
end | if temp == 47 then
print('output')
end | Use ==. | Lua |
[46, 96, 28 | [46, 96, 28] | Close bracket. | Ruby |
let text = String::from("world"); let ref=&text; text.push_str("!"); | let mut text = String::from("world"); let ref=&text; println!("{{}}", ref); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
const val = 1; val = 70; | let val = 1; val = 70; | Cannot reassign const. | JavaScript |
if (count = 9) | if (count == 9) | Use ==. | Scala |
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 |
if (count = 59) {{}} | if (count == 59) {{}} | Use ==. | Kotlin |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
String name = 'test'; | String name = 'test'; | Correct. | Dart |
values.forEach(function(y) {{ console.log(y); }}) | values.forEach((y) => {{ console.log(y); }}) | Arrow functions are cleaner. | JavaScript |
[x*x for x in arr if x > 89] | [x*x for x in arr if x > 89] | Correct list comprehension. | Python |
<br></br> | <br> | Self-closing. | HTML |
.User {{ color: green; }} | .User {{ color: green; }} | Correct. | CSS |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
WHERE status = '30' | WHERE status = 30 | Don't quote integer. | SQL |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
raise 'data' | raise Exception('data') | Raise needs an exception class. | Python |
function process(foo:string){{return foo;}} process(87); | function process(foo:string){{return foo;}} process('value'); | Pass correct type. | TypeScript |
val val = 'test' | val val = "test" | Double quotes. | Kotlin |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.