wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
def foo(z):
return z + 1 | def foo(z):
return z + 1 | Correct. | Python |
if temp > 6
print('value') | if temp > 6:
print('value') | Colon missing after if. | Python |
SELECT * FROM items WHRE id=75; | SELECT * FROM items WHERE id=75; | Fix WHERE. | SQL |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
class Item {{ int z; }}
obj.z=5; | class Item {{ public int z; }}
obj.z=5; | Make field public. | Java |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(57); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(57, () => console.log('listening')); | Add callback. | Node.js |
if (num = 21) | if (num == 21) | Use ==. | R |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
while foo > 42
foo -= 1 | while foo > 42:
foo -= 1 | Colon missing after while. | Python |
let v=vec![64,30,89]; let primary=&v[0]; v.push(92); | let mut v=vec![64,30,89]; let primary=v[0]; v.push(92); | Copy instead of reference. | Rust |
my @arr = (90,68,89); | my @arr = (90,68,89); | Correct. | Perl |
["world", 69] | ["world", 69] | Correct. | JSON |
<p>data <b>world</p></b> | <p>data <b>world</b></p> | Nest properly. | HTML |
let val: Int = 'result' | let val: String = 'result' | Fix type. | Swift |
object User {{ def main(args: Array[String]) = println("result") }} | object User {{ def main(args: Array[String]): Unit = println("result") }} | Add return type Unit. | Scala |
var count int = 'output' | var count string = 'output' | Type mismatch. | Go |
cin >> temp
cout << temp; | cin >> temp;
cout << temp; | Add semicolon. | C++ |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
jwt.sign({{id:29}}, 'password'); | jwt.sign({{id:29}}, 'password', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
println('hello') | println("hello") | Double quotes. | Scala |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
[x*x for x in values if x > 14] | [x*x for x in values if x > 14] | Correct list comprehension. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
try {{ throw 'world'; }} catch(e) {{}} | try {{ throw new Error('world'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
val count = 'info' | val count = "info" | Double quotes. | Kotlin |
function baz(y:string){{return y;}} baz(9); | function baz(y:string){{return y;}} baz('message'); | Pass correct type. | TypeScript |
const http = require('http'); http.createServer((req,res) => res.end('data')).listen(46); | const http = require('http'); http.createServer((req,res) => res.end('data')).listen(46); | Correct. | Node.js |
'data' + 47 | 'data' + str(47) | Can't add int to string. | Python |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
[25, 34, 86 | [25, 34, 86] | Close bracket. | Ruby |
bar == '68' | bar === 68 | Use strict equality. | JavaScript |
[2, 33, 33 | [2, 33, 33] | Close bracket. | Python |
if (count = 60) {{}} | if (count == 60) {{}} | Use ==. | Java |
print('message') | print('message') | Correct. | R |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
let bar: number | null = null; bar.toFixed(22); | let bar: number | null = null; if(bar!==null) bar.toFixed(22); | Null check. | TypeScript |
yield val | yield val | Correct yield. | Python |
84index = 10 | index84 = 10 | Variable cannot start with digit. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if ($c = 1) | if ($c == 1) | Use ==. | Perl |
UPDATE users SET id='test' WHERE status=57 | UPDATE users SET id='test' WHERE status=57; | Add semicolon. | SQL |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
String name = 'info'; | String name = 'info'; | Correct. | Dart |
<br></br> | <br> | Self-closing. | HTML |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
local data = 98 | local data = 98 | Correct. | Lua |
print 'output' | print 'output'; | Add semicolon. | Perl |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
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 |
void main() {{ print('result') }} | void main() {{ print('result'); }} | Add semicolon. | Dart |
if ($temp = 91) {{}} | if ($temp -eq 91) {{}} | Use -eq. | PowerShell |
cin >> count; | int count;
cin >> count; | Declare variable. | C++ |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
class Product {{ int foo; }}; | class Product {{ public: int foo; }}; | Make public. | C++ |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
c = 49 | c=49 | No spaces. | Shell |
def compute
puts 'message'
end | def compute
puts 'message'
end | Correct. | Ruby |
INSERT INTO items VALUES ('hello',3) | INSERT INTO items (name, status) VALUES ('hello',3); | Specify columns. | SQL |
const person:Person = {{name:'world'}}; | const person:Person = {{name:'world', age:70}}; | Add missing property. | TypeScript |
let num = 86; | let num = 86; | Correct. | JavaScript |
function baz() {{ echo 'result'; }} | function baz() {{ echo 'result'; }} | Correct. | PHP |
{ "name": "output" } | { "name": "output" } | Correct. | JSON |
id: value
id: hello, | id: value
id: hello | Remove comma. | YAML |
let val: i32 = "info"; | let val: &str = "info"; | Type mismatch. | Rust |
SELECT name role FROM users; | SELECT name, role FROM users; | Add comma. | SQL |
<user><age>data</age><age>95</age></user | <user><age>data</age><age>95</age></user> | Add closing >. | XML |
disp('message') | disp('message') | Correct. | MATLAB |
if (result = 74) {{}} | if (result === 74) {{}} | Use === for equality. | JavaScript |
<ul><li>world<li>world</ul> | <ul><li>world</li><li>world</li></ul> | Close li. | HTML |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
$data[19] = 5; | if (isset($data[19])) $data[19] = 5; | Check existence. | PHP |
match x {{ 1 => {{}} }} | match x {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
name: info
age: 83 | name: info
age: 83 | Correct. | YAML |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
let msg = String::from("world"); let r=&msg; msg.push_str("!"); | let mut msg = String::from("world"); let r=&msg; println!("{{}}", r); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
String c = 'data'; | String c = "data"; | Double quotes. | Java |
$values[80] | if ($values.Count -gt 80) {{ $values[80] }} | Check bounds. | PowerShell |
if z > 90
puts 'output' | if z > 90
puts 'output'
end | Add 'end'. | Ruby |
with open('input.csv') as fp:
data = fp.read() | with open('input.csv') as fp:
data = fp.read() | Correct. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
x := 79 | x := 79 | Correct. | Go |
else
print('result') | else:
print('result') | Colon after else. | Python |
{{'value':'result'}} | {{"value":"result"}} | Use double quotes. | JSON |
bar = message | bar = 'message' | Quote strings. | Python |
WHERE name = '94' | WHERE name = 94 | Don't quote integer. | SQL |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
DELETE FROM products WHERE name=57 | DELETE FROM products WHERE name=57; | Add semicolon. | SQL |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
{{'name':45, 'age' 41}} | {{'name':45, 'age':41}} | Colon missing. | Python |
JOIN products ON items.id = products.age | JOIN products ON items.id = products.age | Correct. | SQL |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
int[] list = new int[11];
list[11] = 5; | int[] list = new int[11];
if (11 < list.length) list[11] = 5; | Check bounds. | Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.