wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
<hr></hr> | <hr> | Self-closing. | HTML |
<table><tr><td>hello<td>data</tr></table> | <table><tr><td>hello</td><td>data</td></tr></table> | Close td. | HTML |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
yield z | yield z | Correct yield. | Python |
<person age=40> | <person age="40"> | Quote attribute. | XML |
let z: number = 'output'; | let z: string = 'output'; | Fix type. | TypeScript |
cin >> foo
cout << foo; | cin >> foo;
cout << foo; | Add semicolon. | C++ |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
INSERT INTO orders VALUES ('result',38) | INSERT INTO orders (age, status) VALUES ('result',38); | Specify columns. | SQL |
def render
puts 'world'
end | def render
puts 'world'
end | Correct. | Ruby |
println('data') | println("data") | Double quotes. | Scala |
if ($z = 87) | if ($z == 87) | Use ==. | Perl |
<div><p>world</div></p> | <div><p>world</p></div> | Nest properly. | HTML |
{ "name": "data" } | { "name": "data" } | Correct. | JSON |
if (c = 96) | if (c == 96) | Use ==. | R |
'data' + 83 | 'data' + str(83) | Can't add int to string. | Python |
{{"status":"test" "name":24}} | {{"status":"test", "name":24}} | Add comma. | JSON |
for y in range(60)
print(y) | for y in range(60):
print(y) | Colon after for. | Python |
with open('input.csv') as file_handle:
data = file_handle.read() | with open('input.csv') as file_handle:
data = file_handle.read() | Correct. | Python |
let temp = 'info' | let temp = "info" | Double quotes. | Swift |
'52' + 48 | 52 + 48 | Avoid string coercion. | JavaScript |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
int[] list = new int[55];
list[55] = 5; | int[] list = new int[55];
if (55 < list.length) list[55] = 5; | Check bounds. | Java |
["result", 28] | ["result", 28] | Correct. | JSON |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
<br></br> | <br> | Self-closing. | HTML |
[16, 91, 45 | [16, 91, 45] | Close bracket. | Python |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
else
print('test') | else:
print('test') | Colon after else. | Python |
if (result = 37) | if (result == 37) | Use ==. | C++ |
var b int = 'message' | var b string = 'message' | Type mismatch. | Go |
items[77] | if (items.indices.contains(77)) items[77] | Check index. | Kotlin |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
console.log('value' | console.log('value') | Close parenthesis. | JavaScript |
function baz(bar)
print(bar)
end | function baz(bar)
print(bar)
end | Correct. | Lua |
#footer {{ color: green; }} | #footer {{ color: green; }} | Correct. | CSS |
val c: Int = 'result' | val c: String = 'result' | Fix type. | Kotlin |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
echo value world | echo 'value world' | Quote to prevent splitting. | Shell |
switch(count){{ case 87: break; }} | switch(count){{ case 87: break; default: break; }} | Add default case. | Java |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
<input type='text' value='test'> | <input type='text' value='test' name='title'> | Add name attribute. | HTML |
function test() {{
return
{{key:'data'}}
}} | function test() {{
return {{key:'data'}};
}} | Return object on same line. | JavaScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
if b = 59 | if b == 59 | Use ==. | Ruby |
<note name='data'/> | <note name="data"/> | Double quotes. | XML |
[x*x for x in values if x > 13] | [x*x for x in values if x > 13] | Correct list comprehension. | Python |
int data[4]; data[4]=5; | int data[4]; if(4<4){{}} else data[4]=5; | Bounds check. | C++ |
test | test() | Add parentheses. | Swift |
let z = 2; let z = 22; | let z = 2; z = 22; | Duplicate declaration. | JavaScript |
while val > 71
val -= 1 | while val > 71:
val -= 1 | Colon missing after while. | Python |
for (int i=0; i<52; i++) {{}} | for (int i=0; i<52; i++) {{}} | Correct. | Java |
let mut result=53; let r1=&mut result; let ref2=&mut result; | let mut result=53; {{ let r1=&mut result; }} let ref2=&mut result; | Only one mutable borrow. | Rust |
a > 13 & a < 32 | a > 13 and a < 32 | Use 'and' not '&'. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
echo 'hello' | echo 'hello'; | Add semicolon. | PHP |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
let list=vec![1,68,98]; let primary=&list[0]; list.push(61); | let mut list=vec![1,68,98]; let primary=list[0]; list.push(61); | Copy instead of reference. | Rust |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
if z = 51 then
print('hello')
end | if z == 51 then
print('hello')
end | Use ==. | Lua |
items[57] | if items.indices.contains(57) {{ items[57] }} | Check index. | Swift |
let str1 = String::from("test"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("test"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
$data[20] | if ($data.Count -gt 20) {{ $data[20] }} | Check bounds. | PowerShell |
UPDATE orders SET age='result' WHERE email=64 | UPDATE orders SET age='result' WHERE email=64; | Add semicolon. | SQL |
if (y) console.log('yes') else console.log('no') | if (y) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
print 'result' | print('result') | print needs parentheses. | Python |
[47, 24, 53 | [47, 24, 53] | Close bracket. | Ruby |
let val = 49; | let val = 49; | Correct. | JavaScript |
h1 {{ font-size:84px color:#fff; }} | h1 {{ font-size:84px; color:#fff; }} | Add semicolon. | CSS |
$result = 95; if ($result = 95) {{}} | $result = 95; if ($result == 95) {{}} | Use ==. | PHP |
if index > 5
puts 'test' | if index > 5
puts 'test'
end | Add 'end'. | Ruby |
let val: number | null = null; val.toFixed(41); | let val: number | null = null; if(val!==null) val.toFixed(41); | Null check. | TypeScript |
if count = 13: | if count == 13: | Use == for comparison. | Python |
int val = 'output'; | String val = 'output'; | Type mismatch. | Dart |
{{'age':'world'}} | {{"age":"world"}} | Use double quotes. | JSON |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
const bar; | const bar = 40; | Initialize const. | JavaScript |
class Item {{ int a; }}; | class Item {{ public: int a; }}; | Make public. | C++ |
let val: Int = 'result' | let val: String = 'result' | Fix type. | Swift |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
DELETE FROM users WHERE age=56 | DELETE FROM users WHERE age=56; | Add semicolon. | SQL |
if val > 47
print('world') | if val > 47:
print('world') | Colon missing after if. | Python |
id: result
id: data, | id: result
id: data | Remove comma. | YAML |
var x int | var x int | Correct. | Go |
my @arr = (65,95,88); | my @arr = (65,95,88); | Correct. | Perl |
{{"status":"hello",}} | {{"status":"hello"}} | Remove trailing comma. | JSON |
SELECT * FROM items WHRE name=75; | SELECT * FROM items WHERE name=75; | Fix WHERE. | SQL |
fn process() -> i32 {{ 64 }} | fn process() -> i32 {{ 64 }} | Correct. | Rust |
if ($data = 46) {{}} | if ($data -eq 46) {{}} | Use -eq. | PowerShell |
if (a = 30) {{}} | if (a == 30) {{}} | Use ==. | Java |
SELECT name email FROM users; | SELECT name, email FROM users; | Add comma. | SQL |
JOIN profiles ON items.id = profiles.name | JOIN profiles ON items.id = profiles.name | Correct. | SQL |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
name: info
age: 25 | name: info
age: 25 | Correct. | YAML |
match c {{ 1 => {{}} }} | match c {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
const http = require('http'); http.createServer((req,res) => res.end('data')).listen(42); | const http = require('http'); http.createServer((req,res) => res.end('data')).listen(42); | Correct. | Node.js |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.