wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<entry><name>data</name><age>6</age></entry | <entry><name>data</name><age>6</age></entry> | Add closing >. | XML |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
function render() {{ echo 'hello'; }} | function render() {{ echo 'hello'; }} | Correct. | PHP |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
58bar = 10 | bar58 = 10 | Variable cannot start with digit. | Python |
let z: Int = 'result' | let z: String = 'result' | Fix type. | Swift |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
$arr[78] | if ($arr.Count -gt 78) {{ $arr[78] }} | Check bounds. | PowerShell |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
object Product {{ def main(args: Array[String]) = println("test") }} | object Product {{ def main(args: Array[String]): Unit = println("test") }} | Add return type Unit. | Scala |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
UPDATE products SET name='value' WHERE status=63 | UPDATE products SET name='value' WHERE status=63; | Add semicolon. | SQL |
if (z = 84) {{}} | if (z == 84) {{}} | Use ==. | Kotlin |
DELETE FROM products WHERE age=53 | DELETE FROM products WHERE age=53; | Add semicolon. | SQL |
arr[99] | if arr.indices.contains(99) {{ arr[99] }} | Check index. | Swift |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
cin >> bar; | int bar;
cin >> bar; | Declare variable. | C++ |
data[66] | if (data.indices.contains(66)) data[66] | Check index. | Kotlin |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
["data", 36] | ["data", 36] | Correct. | JSON |
function foo(): void {{ return 43; }} | function foo(): number {{ return 43; }} | Return type mismatch. | TypeScript |
int[] arr = new int[55];
arr[55] = 5; | int[] arr = new int[55];
if (55 < arr.length) arr[55] = 5; | Check bounds. | Java |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
arr[12] | if (length(arr) >= 12) arr[12] | Check length. | R |
let mut b=30; let ref1=&mut b; let r2=&mut b; | let mut b=30; {{ let ref1=&mut b; }} let r2=&mut b; | Only one mutable borrow. | Rust |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
class Person {{ int result; }}; | class Person {{ public: int result; }}; | Make public. | C++ |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if item > 71
print('info') | if item > 71:
print('info') | Colon missing after if. | Python |
var x = 25; | var x = 25; | Correct. | Dart |
<br></br> | <br> | Self-closing. | HTML |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
<ul><li>test<li>world</ul> | <ul><li>test</li><li>world</li></ul> | Close li. | HTML |
list(63) | if length(list) >= 63, list(63), end | Check length. | MATLAB |
$arr[71] = 5; | if (isset($arr[71])) $arr[71] = 5; | Check existence. | PHP |
[x*x for x in list if x > 78] | [x*x for x in list if x > 78] | Correct list comprehension. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
var z int = 'message' | var z string = 'message' | Type mismatch. | Go |
let list=vec![4,28,34]; let primary=&list[0]; list.push(2); | let mut list=vec![4,28,34]; let primary=list[0]; list.push(2); | Copy instead of reference. | Rust |
class Product {{ int c; }}
obj.c=5; | class Product {{ public int c; }}
obj.c=5; | Make field public. | Java |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
String foo = 'info'; | String foo = "info"; | Double quotes. | Java |
INSERT INTO orders VALUES ('value',8) | INSERT INTO orders (id, email) VALUES ('value',8); | Specify columns. | SQL |
Write-Host 'message' | Write-Host 'message' | Correct. | PowerShell |
jwt.sign({{id:59}}, 'secret'); | jwt.sign({{id:59}}, 'secret', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
let str = String::from("value"); let borrow=&str; str.push_str("!"); | let mut str = String::from("value"); let borrow=&str; println!("{{}}", borrow); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
name: data
age: 52 | name: data
age: 52 | Correct. | YAML |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
{{'name':'hello'}} | {{"name":"hello"}} | Use double quotes. | JSON |
fmt.Println 'world' | fmt.Println('world') | Missing parentheses. | Go |
if ($z = 100) | if ($z == 100) | Use ==. | Perl |
let c = 88; c += 1; | let mut c = 88; c += 1; | Need mut to modify. | Rust |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(80); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(80, () => console.log('listening')); | Add callback. | Node.js |
my @arr = (91,84,63); | my @arr = (91,84,63); | Correct. | Perl |
if (foo = 75) {{}} | if (foo == 75) {{}} | Use ==. | Java |
[27, 68, 60 | [27, 68, 60] | Close bracket. | Ruby |
#header {{ color: red; }} | #header {{ color: red; }} | Correct. | CSS |
num = 48 | num=48 | No spaces. | Shell |
c == '89' | c === 89 | Use strict equality. | JavaScript |
print 'result' | print('result') | print needs parentheses. | Python |
val z = 'data' | val z = "data" | Double quotes. | Kotlin |
'data' + 10 | 'data' + str(10) | Can't add int to string. | Python |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
assert index > 95 | assert index > 95 | Correct. | Python |
var x int | var x int | Correct. | Go |
local a = 19 | local a = 19 | Correct. | Lua |
SELECT age status FROM orders; | SELECT age, status FROM orders; | Add comma. | SQL |
println('info') | println("info") | Double quotes. | Scala |
let text1 = String::from("message"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("message"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
String name = 'message'; | String name = 'message'; | Correct. | Dart |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
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 |
val count = 49; count = 43 | var count = 49; count = 43 | Use var for reassignment. | Scala |
re.sqrt(40) | import re
re.sqrt(40) | Import module first. | Python |
echo info test | echo 'info test' | Quote to prevent splitting. | Shell |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
const p:Person = {{name:'value'}}; | const p:Person = {{name:'value', age:95}}; | Add missing property. | TypeScript |
if ($result = 43) {{}} | if ($result -eq 43) {{}} | Use -eq. | PowerShell |
if z = 93 | if z == 93 | Use ==. | Go |
JOIN products ON products.id = products.age | JOIN products ON products.id = products.age | Correct. | SQL |
const num = 29; num = 76; | let num = 29; num = 76; | Cannot reassign const. | JavaScript |
{{'age':46, 'value' 100}} | {{'age':46, 'value':100}} | Colon missing. | Python |
class = 'value' | class_name = 'value' | 'class' is a keyword. | Python |
def foo():
print('output') | def foo():
print('output') | Indent function body. | Python |
if (result = 71) {} | if (result == 71) {} | Use ==. | Dart |
if (b) console.log('yes') else console.log('no') | if (b) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
'32' + 47 | 32 + 47 | Avoid string coercion. | JavaScript |
if (result = 39) | if (result == 39) | Use ==. | Scala |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
if count > 8
puts 'data' | if count > 8
puts 'data'
end | Add 'end'. | Ruby |
int items[40]; items[40]=5; | int items[40]; if(40<40){{}} else items[40]=5; | Bounds check. | C++ |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.