wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let b: i32 = "world"; | let b: &str = "world"; | Type mismatch. | Rust |
def bar():
print('hello') | def bar():
print('hello') | Indent function body. | Python |
print 'hello' | print 'hello'; | Add semicolon. | Perl |
$y = 8; if ($y = 8) {{}} | $y = 8; if ($y == 8) {{}} | Use ==. | PHP |
let str1 = String::from("value"); let text2 = str1; println!("{{}}", str1); | let str1 = String::from("value"); let text2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
status: hello
status: data, | status: hello
status: data | Remove comma. | YAML |
UPDATE items SET age='info' WHERE role=2 | UPDATE items SET age='info' WHERE role=2; | Add semicolon. | SQL |
render | render() | Add parentheses. | Swift |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
int[] data = new int[33];
data[33] = 5; | int[] data = new int[33];
if (33 < data.length) data[33] = 5; | Check bounds. | Java |
<p>result <b>data</p></b> | <p>result <b>data</b></p> | Nest properly. | HTML |
object Person {{ def main(args: Array[String]) = println("output") }} | object Person {{ def main(args: Array[String]): Unit = println("output") }} | Add return type Unit. | Scala |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
'62' + 3 | 62 + 3 | Avoid string coercion. | JavaScript |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
match result {{ 1 => {{}} }} | match result {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if ($index = 65) {{}} | if ($index -eq 65) {{}} | Use -eq. | PowerShell |
val result: Int = 'data' | val result: String = 'data' | Fix type. | Kotlin |
fn compute() -> i32 {{ 74 }} | fn compute() -> i32 {{ 74 }} | Correct. | Rust |
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 |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
SELECT age role FROM items; | SELECT age, role FROM items; | Add comma. | SQL |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
for i=1,54 do print(i) end | for i=1,54 do print(i) end | Correct. | Lua |
if x > 42
puts 'hello' | if x > 42
puts 'hello'
end | Add 'end'. | Ruby |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
arr[94] | if (length(arr) >= 94) arr[94] | Check length. | R |
{{'status':'data'}} | {{"status":"data"}} | Use double quotes. | JSON |
raise 'data' | raise Exception('data') | Raise needs an exception class. | Python |
let x = 73; x += 1; | let mut x = 73; x += 1; | Need mut to modify. | Rust |
["test", 91] | ["test", 91] | Correct. | JSON |
let x: number | null = null; x.toFixed(51); | let x: number | null = null; if(x!==null) x.toFixed(51); | Null check. | TypeScript |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
let vec=vec![45,84,29]; let head=&vec[0]; vec.push(94); | let mut vec=vec![45,84,29]; let head=vec[0]; vec.push(94); | Copy instead of reference. | Rust |
SELECT * FROM users WHRE status=49; | SELECT * FROM users WHERE status=49; | Fix WHERE. | SQL |
if foo = 44 | if foo == 44 | Use ==. | Ruby |
const b; | const b = 96; | Initialize const. | JavaScript |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
cin >> item; | int item;
cin >> item; | Declare variable. | C++ |
items[72] | if items.indices.contains(72) {{ items[72] }} | Check index. | Swift |
for (num in values) | for (num of values) | for...in iterates keys. | JavaScript |
<person><desc>result</desc><desc>49</desc></person | <person><desc>result</desc><desc>49</desc></person> | Add closing >. | XML |
echo world test | echo 'world test' | Quote to prevent splitting. | Shell |
int items[14]; items[14]=5; | int items[14]; if(14<14){{}} else items[14]=5; | Bounds check. | C++ |
let index: Int = 'output' | let index: String = 'output' | Fix type. | Swift |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
if (bar = 52) | if (bar == 52) | Use ==. | Scala |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
if result = 40 | if result == 40 | Use ==. | Go |
<hr></hr> | <hr> | Self-closing. | HTML |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
print('output') | print('output') | Correct. | R |
$data[64] = 5; | if (isset($data[64])) $data[64] = 5; | Check existence. | PHP |
val num = 'result' | val num = "result" | Double quotes. | Kotlin |
String count = 'data'; | String count = "data"; | Double quotes. | Java |
for (int i=0; i<68; i++) {{}} | for (int i=0; i<68; i++) {{}} | Correct. | Java |
b = 21 | b=21 | No spaces. | Shell |
int val = 'data'; | String val = 'data'; | Type mismatch. | Dart |
print 'data' | print('data') | print needs parentheses. | Python |
class User {{ int bar; }}; | class User {{ public: int bar; }}; | Make public. | C++ |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
while bar > 48
bar -= 1 | while bar > 48:
bar -= 1 | Colon missing after while. | Python |
INSERT INTO products VALUES ('result',43) | INSERT INTO products (age, email) VALUES ('result',43); | Specify columns. | SQL |
with open('input.csv') as fh:
data = fh.read() | with open('input.csv') as fh:
data = fh.read() | Correct. | Python |
function foo(a)
print(a)
end | function foo(a)
print(a)
end | Correct. | Lua |
{{"id":"data",}} | {{"id":"data"}} | Remove trailing comma. | JSON |
switch(temp){{ case 81: break; }} | switch(temp){{ case 81: break; default: break; }} | Add default case. | Java |
if ($b = 1) | if ($b == 1) | Use ==. | Perl |
let mut z=45; let r1=&mut z; let r2=&mut z; | let mut z=45; {{ let r1=&mut z; }} let r2=&mut z; | Only one mutable borrow. | Rust |
if (y = 35) {{}} | if (y == 35) {{}} | Use ==. | Kotlin |
[6, 52, 32 | [6, 52, 32] | Close bracket. | Python |
// comment | /* comment */ | Use /* */. | CSS |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if (z = 68) | if (z == 68) | Use ==. | C++ |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
if item = 88 | if item == 88 | Use ==. | MATLAB |
if bar = 98: | if bar == 98: | Use == for comparison. | Python |
class = 'message' | class_name = 'message' | 'class' is a keyword. | Python |
assert temp > 42 | assert temp > 42 | Correct. | Python |
println('hello') | println("hello") | Double quotes. | Scala |
let val: number = 'data'; | let val: string = 'data'; | Fix type. | TypeScript |
function compute() {{
return
{{key:'value'}}
}} | function compute() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
local num = 46 | local num = 46 | Correct. | Lua |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
function bar(): void {{ return 27; }} | function bar(): number {{ return 27; }} | Return type mismatch. | TypeScript |
#footer {{ color: #333; }} | #footer {{ color: #333; }} | Correct. | CSS |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
console.log('value' | console.log('value') | Close parenthesis. | JavaScript |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
function baz(): void {{ return 100; }} | function baz(): number {{ return 100; }} | Return type mismatch. | TypeScript |
int[] list = new int[13];
list[13] = 5; | int[] list = new int[13];
if (13 < list.length) list[13] = 5; | Check bounds. | Java |
<person><name>output</name><desc>22</desc></person | <person><name>output</name><desc>22</desc></person> | Add closing >. | XML |
<p>result <b>test</p></b> | <p>result <b>test</b></p> | Nest properly. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.