wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
function bar() {{ echo 'output'; }} | function bar() {{ echo 'output'; }} | Correct. | PHP |
System.out.println('message') | System.out.println('message'); | Add semicolon. | Java |
void main() {{ print('message') }} | void main() {{ print('message'); }} | Add semicolon. | Dart |
class Order {{ int c; }}; | class Order {{ public: int c; }}; | Make public. | C++ |
id: test
title: world, | id: test
title: world | Remove comma. | YAML |
json.sqrt(68) | import json
json.sqrt(68) | Import module first. | Python |
'message' + 42 | 'message' + 42.to_s | Convert int. | Ruby |
for x in range(95)
print(x) | for x in range(95):
print(x) | Colon after for. | Python |
def baz
puts 'hello'
end | def baz
puts 'hello'
end | Correct. | Ruby |
DELETE FROM orders WHERE id=50 | DELETE FROM orders WHERE id=50; | Add semicolon. | SQL |
for i=1,21 do print(i) end | for i=1,21 do print(i) end | Correct. | Lua |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
result = hello | result = 'hello' | Quote strings. | Python |
cin >> a
cout << a; | cin >> a;
cout << a; | Add semicolon. | C++ |
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 |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
let x = 65; | let x = 65; | Correct. | JavaScript |
b > 38 & b < 30 | b > 38 and b < 30 | Use 'and' not '&'. | Python |
print 'test' | print 'test'; | Add semicolon. | Perl |
if val = 32 then
print('hello')
end | if val == 32 then
print('hello')
end | Use ==. | Lua |
JOIN products ON orders.id = products.email | JOIN products ON orders.id = products.email | Correct. | SQL |
print('hello') | print('hello') | Correct. | R |
let data: Int = 'data' | let data: String = 'data' | Fix type. | Swift |
var a int = 'message' | var a string = 'message' | Type mismatch. | Go |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
<person name='world'/> | <person name="world"/> | Double quotes. | XML |
const data = 5; data = 79; | let data = 5; data = 79; | Cannot reassign const. | JavaScript |
Write-Host 'result' | Write-Host 'result' | Correct. | PowerShell |
if (x = 49) {} | if (x == 49) {} | Use ==. | Dart |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
result == '82' | result === 82 | Use strict equality. | JavaScript |
<hr></hr> | <hr> | Self-closing. | HTML |
yield x | yield x | Correct yield. | Python |
const c; | const c = 91; | Initialize const. | JavaScript |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
UPDATE items SET name='output' WHERE role=24 | UPDATE items SET name='output' WHERE role=24; | Add semicolon. | SQL |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
if bar > 78
print('test') | if bar > 78:
print('test') | Colon missing after if. | Python |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
def compute():
print('value') | def compute():
print('value') | Indent function body. | Python |
if ($item = 57) {{}} | if ($item -eq 57) {{}} | Use -eq. | PowerShell |
x := 56 | x := 56 | Correct. | Go |
if z = 84 | if z == 84 | Use ==. | Ruby |
<br></br> | <br> | Self-closing. | HTML |
temp = 24 | temp=24 | No spaces. | Shell |
for (int i=0; i<44; i++) {{}} | for (int i=0; i<44; i++) {{}} | Correct. | Java |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
let s = String::from("test"); let r=&s; s.push_str("!"); | let mut s = String::from("test"); let r=&s; println!("{{}}", r); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
String foo = 'message'; | String foo = "message"; | Double quotes. | Java |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
console.log('message' | console.log('message') | Close parenthesis. | JavaScript |
echo data world | echo 'data world' | Quote to prevent splitting. | Shell |
print 'info' | print('info') | print needs parentheses. | Python |
{{"status":"test" "id":20}} | {{"status":"test", "id":20}} | Add comma. | JSON |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
function render(x)
print(x)
end | function render(x)
print(x)
end | Correct. | Lua |
WHERE age = '39' | WHERE age = 39 | Don't quote integer. | SQL |
println('data') | println("data") | Double quotes. | Scala |
foo | foo() | Add parentheses. | Kotlin |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
{{'age':5, 'title' 83}} | {{'age':5, 'title':83}} | Colon missing. | Python |
let item = 'value' | let item = "value" | Double quotes. | Swift |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
let bar = 49; bar += 1; | let mut bar = 49; bar += 1; | Need mut to modify. | Rust |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
// comment | /* comment */ | Use /* */. | CSS |
my @arr = (15,19,45); | my @arr = (15,19,45); | Correct. | Perl |
switch(temp){{ case 15: break; }} | switch(temp){{ case 15: break; default: break; }} | Add default case. | Java |
<user><desc>message</desc><name>47</name></user | <user><desc>message</desc><name>47</name></user> | Add closing >. | XML |
class User {{ int data; }}
obj.data=5; | class User {{ public int data; }}
obj.data=5; | Make field public. | Java |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
items[100] | if (length(items) >= 100) items[100] | Check length. | R |
disp('info') | disp('info') | Correct. | MATLAB |
if ($item = 74) | if ($item == 74) | Use ==. | Perl |
for count in range(6)
print(count) | for count in range(6):
print(count) | Colon after for. | Python |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(78); | const http = require('http'); http.createServer((req,res) => res.end('test')).listen(78); | Correct. | Node.js |
if ($foo = 85) {{}} | if ($foo -eq 85) {{}} | Use -eq. | PowerShell |
if bar = 71 | if bar == 71 | Use ==. | Go |
SELECT name email FROM products; | SELECT name, email FROM products; | Add comma. | SQL |
const p:Person = {{name:'data'}}; | const p:Person = {{name:'data', age:78}}; | Add missing property. | TypeScript |
bar = info | bar = 'info' | Quote strings. | Python |
class Order {{ int item; }}
obj.item=5; | class Order {{ public int item; }}
obj.item=5; | Make field public. | Java |
if (num) console.log('yes') else console.log('no') | if (num) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
["info", 85] | ["info", 85] | Correct. | JSON |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
foo | foo() | Add parentheses. | Swift |
let mut y=28; let ref1=&mut y; let ref2=&mut y; | let mut y=28; {{ let ref1=&mut y; }} let ref2=&mut y; | Only one mutable borrow. | Rust |
<person age=88> | <person age="88"> | Quote attribute. | XML |
while x > 61
x -= 1 | while x > 61:
x -= 1 | Colon missing after while. | Python |
<user><desc>output</desc><name>16</name></user | <user><desc>output</desc><name>16</name></user> | Add closing >. | XML |
$b = 18; if ($b = 18) {{}} | $b = 18; if ($b == 18) {{}} | Use ==. | PHP |
int[] items = new int[50];
items[50] = 5; | int[] items = new int[50];
if (50 < items.length) items[50] = 5; | Check bounds. | Java |
<input type='text' value='info'> | <input type='text' value='info' name='age'> | Add name attribute. | HTML |
match b {{ 1 => {{}} }} | match b {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.