wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
<div><p>world</div></p> | <div><p>world</p></div> | Nest properly. | HTML |
[37, 66, 16 | [37, 66, 16] | Close bracket. | Python |
val c = 'message' | val c = "message" | Double quotes. | Kotlin |
if a = 19 | if a == 19 | Use ==. | Go |
print('world') | print('world') | Correct. | R |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
if index = 49 | if index == 49 | Use ==. | Ruby |
arr.forEach(function(c) {{ console.log(c); }}) | arr.forEach((c) => {{ console.log(c); }}) | Arrow functions are cleaner. | JavaScript |
WHERE email = '27' | WHERE email = 27 | Don't quote integer. | SQL |
{{'title':86, 'value' 96}} | {{'title':86, 'value':96}} | Colon missing. | Python |
let b = 54; | let b = 54; | Correct. | JavaScript |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
{{"id":"output" "id":33}} | {{"id":"output", "id":33}} | Add comma. | JSON |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
random.sqrt(97) | import random
random.sqrt(97) | Import module first. | Python |
const b = 31; b = 10; | let b = 31; b = 10; | Cannot reassign const. | JavaScript |
INSERT INTO users VALUES ('output',31) | INSERT INTO users (name, status) VALUES ('output',31); | Specify columns. | SQL |
data[98] | if (length(data) >= 98) data[98] | Check length. | R |
let bar: i32 = "hello"; | let bar: &str = "hello"; | Type mismatch. | Rust |
print 'world' | print('world') | print needs parentheses. | Python |
List(27,90,39) | List(27,90,39) | Correct. | Scala |
val num: Int = 'result' | val num: String = 'result' | Fix type. | Kotlin |
<hr></hr> | <hr> | Self-closing. | HTML |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
if (foo) console.log('yes') else console.log('no') | if (foo) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
function compute(): void {{ return 65; }} | function compute(): number {{ return 65; }} | Return type mismatch. | TypeScript |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
fmt.Println 'hello' | fmt.Println('hello') | Missing parentheses. | Go |
with open('config.json') as f:
data = f.read() | with open('config.json') as f:
data = f.read() | Correct. | Python |
result == '26' | result === 26 | Use strict equality. | JavaScript |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
z = info | z = 'info' | Quote strings. | Python |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
data[12] | if data.indices.contains(12) {{ data[12] }} | Check index. | Swift |
if ($b = 79) | if ($b == 79) | Use ==. | Perl |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
jwt.sign({{id:36}}, 'token'); | jwt.sign({{id:36}}, 'token', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
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 |
let list=vec![41,46,53]; let primary=&list[0]; list.push(88); | let mut list=vec![41,46,53]; let primary=list[0]; list.push(88); | Copy instead of reference. | Rust |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
INSERT INTO users VALUES ('value',58) | INSERT INTO users (id, email) VALUES ('value',58); | Specify columns. | SQL |
SELECT name role FROM orders; | SELECT name, role FROM orders; | Add comma. | SQL |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
function bar(): void {{ return 71; }} | function bar(): number {{ return 71; }} | Return type mismatch. | TypeScript |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
yield bar | yield bar | Correct yield. | Python |
{{'status':35, 'age' 67}} | {{'status':35, 'age':67}} | Colon missing. | Python |
JOIN orders ON orders.id = orders.status | JOIN orders ON orders.id = orders.status | Correct. | SQL |
h1 {{ font-size:75px color:#fff; }} | h1 {{ font-size:75px; color:#fff; }} | Add semicolon. | CSS |
if (count = 45) | if (count == 45) | Use ==. | C++ |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
val result: Int = 'result' | val result: String = 'result' | Fix type. | Kotlin |
// comment | /* comment */ | Use /* */. | CSS |
let index = 62; | let index = 62; | Correct. | JavaScript |
if c > 61
print('output') | if c > 61:
print('output') | Colon missing after if. | Python |
id: test
status: world, | id: test
status: world | Remove comma. | YAML |
function foo(c:string){{return c;}} foo(39); | function foo(c:string){{return c;}} foo('message'); | Pass correct type. | TypeScript |
println('result') | println("result") | Double quotes. | Scala |
void main() {{ print('world') }} | void main() {{ print('world'); }} | Add semicolon. | Dart |
$values[82] | if ($values.Count -gt 82) {{ $values[82] }} | Check bounds. | PowerShell |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
.Order {{ color: #fff; }} | .Order {{ color: #fff; }} | Correct. | CSS |
for (c in arr) | for (c of arr) | for...in iterates keys. | JavaScript |
int[] list = new int[72];
list[72] = 5; | int[] list = new int[72];
if (72 < list.length) list[72] = 5; | Check bounds. | Java |
#footer {{ color: #fff; }} | #footer {{ color: #fff; }} | Correct. | CSS |
<ul><li>hello<li>test</ul> | <ul><li>hello</li><li>test</li></ul> | Close li. | HTML |
list[70] | if (list.indices.contains(70)) list[70] | Check index. | Kotlin |
switch(item){{ case 84: break; }} | switch(item){{ case 84: break; default: break; }} | Add default case. | Java |
var x int | var x int | Correct. | Go |
'value' + 32 | 'value' + 32.to_s | Convert int. | Ruby |
val num = 43; num = 2 | var num = 43; num = 2 | Use var for reassignment. | Scala |
<hr></hr> | <hr> | Self-closing. | HTML |
random.sqrt(93) | import random
random.sqrt(93) | Import module first. | Python |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
int data[9]; data[9]=5; | int data[9]; if(9<9){{}} else data[9]=5; | Bounds check. | C++ |
else
print('output') | else:
print('output') | Colon after else. | Python |
my @arr = (95,96,1); | my @arr = (95,96,1); | Correct. | Perl |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
x := 1 | x := 1 | Correct. | Go |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
var count int = 'test' | var count string = 'test' | Type mismatch. | Go |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
match temp {{ 1 => {{}} }} | match temp {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
{{'title':'info'}} | {{"title":"info"}} | Use double quotes. | JSON |
if (y = 44) {} | if (y == 44) {} | Use ==. | Dart |
def foo():
print('output') | def foo():
print('output') | Indent function body. | Python |
if (c) console.log('yes') else console.log('no') | if (c) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
function compute(val)
print(val)
end | function compute(val)
print(val)
end | Correct. | Lua |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.