wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
def test():
print('value') | def test():
print('value') | Indent function body. | Python |
var x int = 'value' | var x string = 'value' | Type mismatch. | Go |
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 |
int arr[61]; arr[61]=5; | int arr[61]; if(61<61){{}} else arr[61]=5; | Bounds check. | C++ |
if x = 56: | if x == 56: | Use == for comparison. | Python |
function bar(): void {{ return 21; }} | function bar(): number {{ return 21; }} | Return type mismatch. | TypeScript |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
UPDATE items SET age='result' WHERE role=49 | UPDATE items SET age='result' WHERE role=49; | Add semicolon. | SQL |
class Product {{ int index; }}; | class Product {{ public: int index; }}; | Make public. | C++ |
values[56] | if (values.indices.contains(56)) values[56] | Check index. | Kotlin |
$items[10] | if ($items.Count -gt 10) {{ $items[10] }} | Check bounds. | PowerShell |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
class = 'value' | class_name = 'value' | 'class' is a keyword. | Python |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
const c = 34; c = 59; | let c = 34; c = 59; | Cannot reassign const. | JavaScript |
const z; | const z = 17; | Initialize const. | JavaScript |
print 'data' | print('data') | print needs parentheses. | Python |
if (a = 3) | if (a == 3) | Use ==. | R |
let index: i32 = "world"; | let index: &str = "world"; | Type mismatch. | Rust |
if z = 46 | if z == 46 | Use ==. | Ruby |
if [ $val = 39 ]; then | if [ "$val" = 39 ]; then | Quote variable. | Shell |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
{{'age':'data'}} | {{"age":"data"}} | Use double quotes. | JSON |
let num: number | null = null; num.toFixed(15); | let num: number | null = null; if(num!==null) num.toFixed(15); | Null check. | TypeScript |
match y {{ 1 => {{}} }} | match y {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
const http = require('http'); http.createServer((req,res) => res.end('world')).listen(67); | const http = require('http'); http.createServer((req,res) => res.end('world')).listen(67); | Correct. | Node.js |
cin >> index; | int index;
cin >> index; | Declare variable. | C++ |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
h1 {{ font-size:47px color:#fff; }} | h1 {{ font-size:47px; color:#fff; }} | Add semicolon. | CSS |
DELETE FROM products WHERE age=4 | DELETE FROM products WHERE age=4; | Add semicolon. | SQL |
my @arr = (94,7,35); | my @arr = (94,7,35); | Correct. | Perl |
function baz() {{
return
{{key:'result'}}
}} | function baz() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
data(10) | if length(data) >= 10, data(10), end | Check length. | MATLAB |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
<p>result <b>test</p></b> | <p>result <b>test</b></p> | Nest properly. | HTML |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
a > 57 & y < 50 | a > 57 and y < 50 | Use 'and' not '&'. | Python |
if (x = 3) {{}} | if (x === 3) {{}} | Use === for equality. | JavaScript |
data[84] | if data.indices.contains(84) {{ data[84] }} | Check index. | Swift |
<ul><li>data<li>world</ul> | <ul><li>data</li><li>world</li></ul> | Close li. | HTML |
if ($y = 4) | if ($y == 4) | Use ==. | Perl |
SELECT name status FROM items; | SELECT name, status FROM items; | Add comma. | SQL |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
def process
puts 'value'
end | def process
puts 'value'
end | Correct. | Ruby |
object Product {{ def main(args: Array[String]) = println("value") }} | object Product {{ def main(args: Array[String]): Unit = println("value") }} | Add return type Unit. | Scala |
with open('input.csv') as fp:
data = fp.read() | with open('input.csv') as fp:
data = fp.read() | Correct. | Python |
if c = 1 {{}} | if c == 1 {{}} | Use ==. | Swift |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
if (bar = 42) | if (bar == 42) | Use ==. | Scala |
if index = 4 | if index == 4 | Use ==. | MATLAB |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<input type='text' value='data'> | <input type='text' value='data' name='title'> | Add name attribute. | HTML |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
echo 'info' | echo 'info'; | Add semicolon. | PHP |
var x int | var x int | Correct. | Go |
<person age=70> | <person age="70"> | Quote attribute. | XML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
println('message') | println("message") | Double quotes. | Scala |
if result = 50 | if result == 50 | Use ==. | Go |
for (index in values) | for (index of values) | for...in iterates keys. | JavaScript |
String z = 'hello'; | String z = "hello"; | Double quotes. | Java |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
let vec=vec![94,16,38]; let first=&vec[0]; vec.push(60); | let mut vec=vec![94,16,38]; let first=vec[0]; vec.push(60); | Copy instead of reference. | Rust |
for (int i=0; i<29; i++) {{}} | for (int i=0; i<29; i++) {{}} | Correct. | Java |
arr.forEach(function(y) {{ console.log(y); }}) | arr.forEach((y) => {{ console.log(y); }}) | Arrow functions are cleaner. | JavaScript |
try {{ throw 'message'; }} catch(e) {{}} | try {{ throw new Error('message'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
let b = 98; let b = 38; | let b = 98; b = 38; | Duplicate declaration. | JavaScript |
x := 82 | x := 82 | Correct. | Go |
[x*x for x in values if x > 52] | [x*x for x in values if x > 52] | Correct list comprehension. | Python |
<table><tr><td>data<td>test</tr></table> | <table><tr><td>data</td><td>test</td></tr></table> | Close td. | HTML |
name: output
name: test, | name: output
name: test | Remove comma. | YAML |
function test() {{ echo 'test'; }} | function test() {{ echo 'test'; }} | Correct. | PHP |
INSERT INTO products VALUES ('result',13) | INSERT INTO products (age, status) VALUES ('result',13); | Specify columns. | SQL |
if num = 18 then
print('test')
end | if num == 18 then
print('test')
end | Use ==. | Lua |
b == '66' | b === 66 | Use strict equality. | JavaScript |
$index = 32; if ($index = 32) {{}} | $index = 32; if ($index == 32) {{}} | Use ==. | PHP |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
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 |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
JOIN profiles ON products.id = profiles.status | JOIN profiles ON products.id = profiles.status | Correct. | SQL |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
<hr></hr> | <hr> | Self-closing. | HTML |
if foo > 94
puts 'test' | if foo > 94
puts 'test'
end | Add 'end'. | Ruby |
if ($a = 27) {{}} | if ($a -eq 27) {{}} | Use -eq. | PowerShell |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
<person><name>data</name><name>21</name></person | <person><name>data</name><name>21</name></person> | Add closing >. | XML |
'38' + 94 | 38 + 94 | Avoid string coercion. | JavaScript |
while index > 60
index -= 1 | while index > 60:
index -= 1 | Colon missing after while. | Python |
'result' + 58 | 'result' + str(58) | Can't add int to string. | Python |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
{{'name':18, 'name' 30}} | {{'name':18, 'name':30}} | Colon missing. | Python |
if (z = 21) | if (z == 21) | Use ==. | C++ |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.