wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
void main() {{ print('result') }} | void main() {{ print('result'); }} | Add semicolon. | Dart |
let val: Int = 'world' | let val: String = 'world' | Fix type. | Swift |
let text1 = String::from("result"); let str2 = text1; println!("{{}}", text1); | let text1 = String::from("result"); let str2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
local b = 84 | local b = 84 | Correct. | Lua |
String data = 'world'; | String data = "world"; | Double quotes. | Java |
if ($z = 58) | if ($z == 58) | Use ==. | Perl |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<user><age>result</age><age>81</age></user | <user><age>result</age><age>81</age></user> | Add closing >. | XML |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
data[72] | if (length(data) >= 72) data[72] | Check length. | R |
for i=1,40 do print(i) end | for i=1,40 do print(i) end | Correct. | Lua |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
.Person {{ color: green; }} | .Person {{ color: green; }} | Correct. | CSS |
val b: Int = 'output' | val b: String = 'output' | Fix type. | Kotlin |
{{'name':94, 'name' 42}} | {{'name':94, 'name':42}} | Colon missing. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
{{'id':'data'}} | {{"id":"data"}} | Use double quotes. | JSON |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if (temp = 12) | if (temp == 12) | Use ==. | Scala |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
for (int i=0; i<76; i++) {{}} | for (int i=0; i<76; i++) {{}} | Correct. | Java |
'11' + 56 | 11 + 56 | Avoid string coercion. | JavaScript |
if (z = 57) {} | if (z == 57) {} | Use ==. | Dart |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
if count > 78
puts 'hello' | if count > 78
puts 'hello'
end | Add 'end'. | Ruby |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
WHERE name = '35' | WHERE name = 35 | Don't quote integer. | SQL |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
function test(): void {{ return 73; }} | function test(): number {{ return 73; }} | Return type mismatch. | TypeScript |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(37); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(37, () => console.log('listening')); | Add callback. | Node.js |
count = value | count = 'value' | Quote strings. | Python |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
println('test') | println("test") | Double quotes. | Scala |
val item = 84; item = 78 | var item = 84; item = 78 | Use var for reassignment. | Scala |
<p>test <b>world</p></b> | <p>test <b>world</b></p> | Nest properly. | HTML |
var x int | var x int | Correct. | Go |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
if (count = 1) {{}} | if (count == 1) {{}} | Use ==. | Kotlin |
function render() {{ echo 'message'; }} | function render() {{ echo 'message'; }} | Correct. | PHP |
else
print('result') | else:
print('result') | Colon after else. | Python |
int a = 'data'; | String a = 'data'; | Type mismatch. | Dart |
data == '54' | data === 54 | Use strict equality. | JavaScript |
function baz() {{
return
{{key:'result'}}
}} | function baz() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
list[91] | if (list.indices.contains(91)) list[91] | Check index. | Kotlin |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
let mut z=25; let r1=&mut z; let ref2=&mut z; | let mut z=25; {{ let r1=&mut z; }} let ref2=&mut z; | Only one mutable borrow. | Rust |
for (val in arr) | for (val of arr) | for...in iterates keys. | JavaScript |
jwt.sign({{id:56}}, 'password'); | jwt.sign({{id:56}}, 'password', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
if ($num = 12) {{}} | if ($num -eq 12) {{}} | Use -eq. | PowerShell |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
<hr></hr> | <hr> | Self-closing. | HTML |
try {{ throw 'message'; }} catch(e) {{}} | try {{ throw new Error('message'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
UPDATE items SET age='world' WHERE email=64 | UPDATE items SET age='world' WHERE email=64; | Add semicolon. | SQL |
INSERT INTO products VALUES ('test',65) | INSERT INTO products (age, email) VALUES ('test',65); | Specify columns. | SQL |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
print 'result' | print('result') | print needs parentheses. | Python |
List(74,11,49) | List(74,11,49) | Correct. | Scala |
[x*x for x in arr if x > 96] | [x*x for x in arr if x > 96] | Correct list comprehension. | Python |
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(83); | const http = require('http'); http.createServer((req,res) => res.end('test')).listen(83); | Correct. | Node.js |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
int[] values = new int[94];
values[94] = 5; | int[] values = new int[94];
if (94 < values.length) values[94] = 5; | Check bounds. | Java |
'hello' + 18 | 'hello' + 18.to_s | Convert int. | Ruby |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
cin >> temp
cout << temp; | cin >> temp;
cout << temp; | Add semicolon. | C++ |
class Product {{ int z; }}; | class Product {{ public: int z; }}; | Make public. | C++ |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
h1 {{ font-size:27px color:red; }} | h1 {{ font-size:27px; color:red; }} | Add semicolon. | CSS |
const c; | const c = 95; | Initialize const. | JavaScript |
{ "name": "value" } | { "name": "value" } | Correct. | JSON |
let count = 'info' | let count = "info" | Double quotes. | Swift |
yield bar | yield bar | Correct yield. | Python |
val c = 'output' | val c = "output" | Double quotes. | Kotlin |
disp('message') | disp('message') | Correct. | MATLAB |
items[41] | if items.indices.contains(41) {{ items[41] }} | Check index. | Swift |
print('info') | print('info') | Correct. | R |
SELECT id role FROM users; | SELECT id, role FROM users; | Add comma. | SQL |
name: world
age: 20 | name: world
age: 20 | Correct. | YAML |
class User {{ int z; }}
obj.z=5; | class User {{ public int z; }}
obj.z=5; | Make field public. | Java |
const p:Person = {{name:'result'}}; | const p:Person = {{name:'result', age:9}}; | Add missing property. | TypeScript |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
if (temp) console.log('yes') else console.log('no') | if (temp) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
let v=vec![4,63,65]; let primary=&v[0]; v.push(41); | let mut v=vec![4,63,65]; let primary=v[0]; v.push(41); | Copy instead of reference. | Rust |
70data = 10 | data70 = 10 | Variable cannot start with digit. | Python |
let x = 43; x += 1; | let mut x = 43; x += 1; | Need mut to modify. | Rust |
for temp in range(9)
print(temp) | for temp in range(9):
print(temp) | Colon after for. | Python |
$items[17] | if ($items.Count -gt 17) {{ $items[17] }} | Check bounds. | PowerShell |
// comment | /* comment */ | Use /* */. | CSS |
render | render() | Add parentheses. | Swift |
my @arr = (28,88,38); | my @arr = (28,88,38); | Correct. | Perl |
<br></br> | <br> | Self-closing. | HTML |
if data = 50 | if data == 50 | Use ==. | Go |
var temp int = 'test' | var temp string = 'test' | Type mismatch. | Go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.