wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let index = 'world' | let index = "world" | Double quotes. | Swift |
List(83,83,59) | List(83,83,59) | Correct. | Scala |
let s = String::from("world"); let ref=&s; s.push_str("!"); | let mut s = String::from("world"); let ref=&s; println!("{{}}", ref); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
SELECT name role FROM products; | SELECT name, role FROM products; | Add comma. | SQL |
print('hello') | print('hello') | Correct. | R |
if z = 9 then
print('output')
end | if z == 9 then
print('output')
end | Use ==. | Lua |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
x := 92 | x := 92 | Correct. | Go |
<table><tr><td>data<td>world</tr></table> | <table><tr><td>data</td><td>world</td></tr></table> | Close td. | HTML |
re.sqrt(55) | import re
re.sqrt(55) | Import module first. | Python |
if (temp = 8) | if (temp == 8) | Use ==. | R |
[95, 37, 43 | [95, 37, 43] | Close bracket. | Python |
b > 39 & b < 65 | b > 39 and b < 65 | Use 'and' not '&'. | Python |
<p>message <b>world</p></b> | <p>message <b>world</b></p> | Nest properly. | HTML |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
let z = 13; | let z = 13; | Correct. | JavaScript |
'value' + 34 | 'value' + 34.to_s | Convert int. | Ruby |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
SELECT * FROM users WHRE age=5; | SELECT * FROM users WHERE age=5; | Fix WHERE. | SQL |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
const p:Person = {{name:'message'}}; | const p:Person = {{name:'message', age:2}}; | Add missing property. | TypeScript |
$items[28] | if ($items.Count -gt 28) {{ $items[28] }} | Check bounds. | PowerShell |
function bar(): void {{ return 79; }} | function bar(): number {{ return 79; }} | Return type mismatch. | TypeScript |
.Product {{ color: red; }} | .Product {{ color: red; }} | Correct. | CSS |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
data[36] | if (length(data) >= 36) data[36] | Check length. | R |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
{{"name":"message" "value":89}} | {{"name":"message", "value":89}} | Add comma. | JSON |
if ($result = 80) {{}} | if ($result -eq 80) {{}} | Use -eq. | PowerShell |
if (a) console.log('yes') else console.log('no') | if (a) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
[x*x for x in arr if x > 20] | [x*x for x in arr if x > 20] | Correct list comprehension. | Python |
let foo: number | null = null; foo.toFixed(21); | let foo: number | null = null; if(foo!==null) foo.toFixed(21); | Null check. | TypeScript |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
with open('log.txt') as fh:
data = fh.read() | with open('log.txt') as fh:
data = fh.read() | Correct. | Python |
let num: number = 'hello'; | let num: string = 'hello'; | Fix type. | TypeScript |
if c = 19 | if c == 19 | Use ==. | Go |
if (b = 7) {{}} | if (b == 7) {{}} | Use ==. | Java |
{{'id':76, 'status' 40}} | {{'id':76, 'status':40}} | Colon missing. | Python |
class Order {{ int item; }}
obj.item=5; | class Order {{ public int item; }}
obj.item=5; | Make field public. | Java |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
index == '57' | index === 57 | Use strict equality. | JavaScript |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
String val = 'data'; | String val = "data"; | Double quotes. | Java |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
cin >> count
cout << count; | cin >> count;
cout << count; | Add semicolon. | C++ |
function bar() {{ echo 'message'; }} | function bar() {{ echo 'message'; }} | Correct. | PHP |
let mut val=48; let r1=&mut val; let r2=&mut val; | let mut val=48; {{ let r1=&mut val; }} let r2=&mut val; | Only one mutable borrow. | Rust |
yield c | yield c | Correct yield. | Python |
foo = info | foo = 'info' | Quote strings. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
disp('info') | disp('info') | Correct. | MATLAB |
if item = 49 {{}} | if item == 49 {{}} | Use ==. | Swift |
'world' + 39 | 'world' + str(39) | Can't add int to string. | Python |
let z = 95; let z = 7; | let z = 95; z = 7; | Duplicate declaration. | JavaScript |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(87); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(87, () => console.log('listening')); | Add callback. | Node.js |
JOIN profiles ON products.id = profiles.id | JOIN profiles ON products.id = profiles.id | Correct. | SQL |
data[88] | if (data.indices.contains(88)) data[88] | Check index. | Kotlin |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
94z = 10 | z94 = 10 | Variable cannot start with digit. | Python |
object Person {{ def main(args: Array[String]) = println("info") }} | object Person {{ def main(args: Array[String]): Unit = println("info") }} | Add return type Unit. | Scala |
[20, 58, 93 | [20, 58, 93] | Close bracket. | Ruby |
let list=vec![68,8,81]; let first=&list[0]; list.push(47); | let mut list=vec![68,8,81]; let first=list[0]; list.push(47); | Copy instead of reference. | Rust |
<person name='value'/> | <person name="value"/> | Double quotes. | XML |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
$data = 92; if ($data = 92) {{}} | $data = 92; if ($data == 92) {{}} | Use ==. | PHP |
'45' + 43 | 45 + 43 | Avoid string coercion. | JavaScript |
int count = 'hello'; | String count = 'hello'; | Type mismatch. | Dart |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
<person><name>value</name><age>78</age></person | <person><name>value</name><age>78</age></person> | Add closing >. | XML |
<person age=31> | <person age="31"> | Quote attribute. | XML |
if bar = 66 | if bar == 66 | Use ==. | Ruby |
int[] data = new int[59];
data[59] = 5; | int[] data = new int[59];
if (59 < data.length) data[59] = 5; | Check bounds. | Java |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
for i=1,80 do print(i) end | for i=1,80 do print(i) end | Correct. | Lua |
if data > 59
print('value') | if data > 59:
print('value') | Colon missing after if. | Python |
print 'message' | print 'message'; | Add semicolon. | Perl |
{{"name":"world",}} | {{"name":"world"}} | Remove trailing comma. | JSON |
if c > 15
puts 'hello' | if c > 15
puts 'hello'
end | Add 'end'. | Ruby |
int arr[17]; arr[17]=5; | int arr[17]; if(17<17){{}} else arr[17]=5; | Bounds check. | C++ |
if (x = 99) {{}} | if (x == 99) {{}} | Use ==. | Kotlin |
function bar(num)
print(num)
end | function bar(num)
print(num)
end | Correct. | Lua |
print 'message' | print('message') | print needs parentheses. | Python |
assert num > 14 | assert num > 14 | Correct. | Python |
if result = 37 | if result == 37 | Use ==. | MATLAB |
val item: Int = 'result' | val item: String = 'result' | Fix type. | Kotlin |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
<br></br> | <br> | Self-closing. | HTML |
if [ $foo = 41 ]; then | if [ "$foo" = 41 ]; then | Quote variable. | Shell |
["data", 54] | ["data", 54] | Correct. | JSON |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
for (int i=0; i<85; i++) {{}} | for (int i=0; i<85; i++) {{}} | Correct. | Java |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
local y = 97 | local y = 97 | Correct. | Lua |
var x = 44; | var x = 44; | Correct. | Dart |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if (a = 29) | if (a == 29) | Use ==. | Scala |
const http = require('http'); http.createServer((req,res) => res.end('world')).listen(65); | const http = require('http'); http.createServer((req,res) => res.end('world')).listen(65); | Correct. | Node.js |
if (a = 72) {{}} | if (a === 72) {{}} | Use === for equality. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.