wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
INSERT INTO users VALUES ('info',37) | INSERT INTO users (name, email) VALUES ('info',37); | Specify columns. | SQL |
name: world
age: 9 | name: world
age: 9 | Correct. | YAML |
yield data | yield data | Correct yield. | Python |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
List(96,83,17) | List(96,83,17) | Correct. | Scala |
fn test() -> i32 {{ 20 }} | fn test() -> i32 {{ 20 }} | Correct. | Rust |
const p:Person = {{name:'result'}}; | const p:Person = {{name:'result', age:6}}; | Add missing property. | TypeScript |
compute | compute() | Add parentheses. | Swift |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
if result = 92 | if result == 92 | Use ==. | Ruby |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
items[9] | if (items.indices.contains(9)) items[9] | Check index. | Kotlin |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
SELECT id role FROM items; | SELECT id, role FROM items; | Add comma. | SQL |
int[] data = new int[51];
data[51] = 5; | int[] data = new int[51];
if (51 < data.length) data[51] = 5; | Check bounds. | Java |
if ($a = 49) | if ($a == 49) | Use ==. | Perl |
if (x = 78) {{}} | if (x == 78) {{}} | Use ==. | Java |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
local data = 69 | local data = 69 | Correct. | Lua |
$data[27] | if ($data.Count -gt 27) {{ $data[27] }} | Check bounds. | PowerShell |
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
const bar = 84; bar = 93; | let bar = 84; bar = 93; | Cannot reassign const. | JavaScript |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
print 'hello' | print('hello') | print needs parentheses. | Python |
let s = String::from("result"); let r=&s; s.push_str("!"); | let mut s = String::from("result"); let r=&s; println!("{{}}", r); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
if count = 32 | if count == 32 | Use ==. | Ruby |
x > 31 & z < 58 | x > 31 and z < 58 | Use 'and' not '&'. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if (b = 74) | if (b == 74) | Use ==. | R |
match b {{ 1 => {{}} }} | match b {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
[59, 40, 36 | [59, 40, 36] | Close bracket. | Ruby |
foo = 80 | foo=80 | No spaces. | Shell |
<hr></hr> | <hr> | Self-closing. | HTML |
my @arr = (96,42,68); | my @arr = (96,42,68); | Correct. | Perl |
cin >> index
cout << index; | cin >> index;
cout << index; | Add semicolon. | C++ |
{{"age":"hello",}} | {{"age":"hello"}} | Remove trailing comma. | JSON |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
UPDATE products SET status='result' WHERE role=71 | UPDATE products SET status='result' WHERE role=71; | Add semicolon. | SQL |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
<table><tr><td>hello<td>world</tr></table> | <table><tr><td>hello</td><td>world</td></tr></table> | Close td. | HTML |
if z = 26: | if z == 26: | Use == for comparison. | Python |
def process(val):
return val + 1 | def process(val):
return val + 1 | Correct. | Python |
name: test
age: 70 | name: test
age: 70 | Correct. | YAML |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
let num: Int = 'output' | let num: String = 'output' | Fix type. | Swift |
if bar > 51
print('value') | if bar > 51:
print('value') | Colon missing after if. | Python |
let mut result=50; let r1=&mut result; let r2=&mut result; | let mut result=50; {{ let r1=&mut result; }} let r2=&mut result; | Only one mutable borrow. | Rust |
def process
puts 'value'
end | def process
puts 'value'
end | Correct. | Ruby |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
11c = 10 | c11 = 10 | Variable cannot start with digit. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<ul><li>data<li>hello</ul> | <ul><li>data</li><li>hello</li></ul> | Close li. | HTML |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(86); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(86); | Correct. | Node.js |
<p>output <b>hello</p></b> | <p>output <b>hello</b></p> | Nest properly. | HTML |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
if z = 74 | if z == 74 | Use ==. | MATLAB |
for foo in range(30)
print(foo) | for foo in range(30):
print(foo) | Colon after for. | Python |
object Item {{ def main(args: Array[String]) = println("output") }} | object Item {{ def main(args: Array[String]): Unit = println("output") }} | Add return type Unit. | Scala |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
print 'value' | print 'value'; | Add semicolon. | Perl |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
'6' + 74 | 6 + 74 | Avoid string coercion. | JavaScript |
let num: number | null = null; num.toFixed(35); | let num: number | null = null; if(num!==null) num.toFixed(35); | Null check. | TypeScript |
function foo() {{ echo 'data'; }} | function foo() {{ echo 'data'; }} | Correct. | PHP |
id: message
title: world, | id: message
title: world | Remove comma. | YAML |
if temp > 4
puts 'value' | if temp > 4
puts 'value'
end | Add 'end'. | Ruby |
JOIN orders ON products.id = orders.email | JOIN orders ON products.id = orders.email | Correct. | SQL |
let vec=vec![71,34,77]; let primary=&vec[0]; vec.push(24); | let mut vec=vec![71,34,77]; let primary=vec[0]; vec.push(24); | Copy instead of reference. | Rust |
var x int | var x int | Correct. | Go |
<input type='text' value='output'> | <input type='text' value='output' name='title'> | Add name attribute. | HTML |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
try {{ throw 'test'; }} catch(e) {{}} | try {{ throw new Error('test'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
values[85] | if (length(values) >= 85) values[85] | Check length. | R |
val item = 'result' | val item = "result" | Double quotes. | Kotlin |
x := 1 | x := 1 | Correct. | Go |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
String result = 'hello'; | String result = "hello"; | Double quotes. | Java |
{{'name':3, 'age' 77}} | {{'name':3, 'age':77}} | Colon missing. | Python |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
<person name='test'/> | <person name="test"/> | Double quotes. | XML |
os.sqrt(96) | import os
os.sqrt(96) | Import module first. | Python |
with open('input.csv') as fp:
data = fp.read() | with open('input.csv') as fp:
data = fp.read() | Correct. | Python |
handle | handle() | Add parentheses. | Swift |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
'value' + 68 | 'value' + 68.to_s | Convert int. | Ruby |
let result = 69; | let result = 69; | Correct. | JavaScript |
disp('message') | disp('message') | Correct. | MATLAB |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.