wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
let text = String::from("result"); let r=&text; text.push_str("!"); | let mut text = String::from("result"); let r=&text; println!("{{}}", r); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
List(99,64,87) | List(99,64,87) | Correct. | Scala |
if [ $num = 44 ]; then | if [ "$num" = 44 ]; then | Quote variable. | Shell |
num == '68' | num === 68 | Use strict equality. | JavaScript |
<person age=89> | <person age="89"> | Quote attribute. | XML |
fn bar() -> i32 {{ 77 }} | fn bar() -> i32 {{ 77 }} | Correct. | Rust |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
json.sqrt(68) | import json
json.sqrt(68) | Import module first. | Python |
class Order {{ int bar; }}
obj.bar=5; | class Order {{ public int bar; }}
obj.bar=5; | Make field public. | Java |
<hr></hr> | <hr> | Self-closing. | HTML |
for x in range(28)
print(x) | for x in range(28):
print(x) | Colon after for. | Python |
if a = 70 {{}} | if a == 70 {{}} | Use ==. | Swift |
SELECT * FROM users WHRE id=72; | SELECT * FROM users WHERE id=72; | Fix WHERE. | SQL |
let a: number | null = null; a.toFixed(83); | let a: number | null = null; if(a!==null) a.toFixed(83); | Null check. | TypeScript |
h1 {{ font-size:29px color:#fff; }} | h1 {{ font-size:29px; color:#fff; }} | Add semicolon. | CSS |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
let a: Int = 'test' | let a: String = 'test' | Fix type. | Swift |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
x := 93 | x := 93 | Correct. | Go |
items[21] | if items.indices.contains(21) {{ items[21] }} | Check index. | Swift |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
for i=1,2 do print(i) end | for i=1,2 do print(i) end | Correct. | Lua |
render | render() | Add parentheses. | Swift |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
'7' + 5 | 7 + 5 | Avoid string coercion. | JavaScript |
if [ $x = 57 ]; then | if [ "$x" = 57 ]; then | Quote variable. | Shell |
'result' + 12 | 'result' + 12.to_s | Convert int. | Ruby |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
<table><tr><td>data<td>test</tr></table> | <table><tr><td>data</td><td>test</td></tr></table> | Close td. | HTML |
cin >> data
cout << data; | cin >> data;
cout << data; | Add semicolon. | C++ |
var index int = 'info' | var index string = 'info' | Type mismatch. | Go |
const val = 92; val = 78; | let val = 92; val = 78; | Cannot reassign const. | JavaScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
WHERE email = '42' | WHERE email = 42 | Don't quote integer. | SQL |
<p>hello <b>world</p></b> | <p>hello <b>world</b></p> | Nest properly. | HTML |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
[80, 85, 16 | [80, 85, 16] | Close bracket. | Python |
const user:Person = {{name:'output'}}; | const user:Person = {{name:'output', age:26}}; | Add missing property. | TypeScript |
def render(item):
return item + 1 | def render(item):
return item + 1 | Correct. | Python |
{ "name": "message" } | { "name": "message" } | Correct. | JSON |
if ($data = 20) | if ($data == 20) | Use ==. | Perl |
SELECT name role FROM users; | SELECT name, role FROM users; | Add comma. | SQL |
function render() {{ echo 'value'; }} | function render() {{ echo 'value'; }} | Correct. | PHP |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
if (index = 51) {{}} | if (index === 51) {{}} | Use === for equality. | JavaScript |
switch(c){{ case 64: break; }} | switch(c){{ case 64: break; default: break; }} | Add default case. | Java |
for (int i=0; i<84; i++) {{}} | for (int i=0; i<84; i++) {{}} | Correct. | Java |
val z: Int = 'message' | val z: String = 'message' | Fix type. | Kotlin |
age: world
status: test, | age: world
status: test | Remove comma. | YAML |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
let index: i32 = "value"; | let index: &str = "value"; | Type mismatch. | Rust |
echo info world | echo 'info world' | Quote to prevent splitting. | Shell |
disp('data') | disp('data') | Correct. | MATLAB |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
try {{ throw 'world'; }} catch(e) {{}} | try {{ throw new Error('world'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
DELETE FROM products WHERE name=43 | DELETE FROM products WHERE name=43; | Add semicolon. | SQL |
["result", 48] | ["result", 48] | Correct. | JSON |
if (c = 100) | if (c == 100) | Use ==. | R |
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(7); | const http = require('http'); http.createServer((req,res) => res.end('test')).listen(7); | Correct. | Node.js |
75val = 10 | val75 = 10 | Variable cannot start with digit. | Python |
let s1 = String::from("test"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("test"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
cin >> z; | int z;
cin >> z; | Declare variable. | C++ |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
a = 89 | a=89 | No spaces. | Shell |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
{{"name":"value" "title":72}} | {{"name":"value", "title":72}} | Add comma. | JSON |
let foo = 77; foo += 1; | let mut foo = 77; foo += 1; | Need mut to modify. | Rust |
with open('config.json') as file_handle:
data = file_handle.read() | with open('config.json') as file_handle:
data = file_handle.read() | Correct. | Python |
var x = 18; | var x = 18; | Correct. | Dart |
<user><desc>output</desc><name>4</name></user | <user><desc>output</desc><name>4</name></user> | Add closing >. | XML |
#content {{ color: green; }} | #content {{ color: green; }} | Correct. | CSS |
if (y) console.log('yes') else console.log('no') | if (y) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
yield a | yield a | Correct yield. | Python |
if ($x = 78) {{}} | if ($x -eq 78) {{}} | Use -eq. | PowerShell |
let data: number = 'hello'; | let data: string = 'hello'; | Fix type. | TypeScript |
class Order {{ int count; }}; | class Order {{ public: int count; }}; | Make public. | C++ |
def render():
print('value') | def render():
print('value') | Indent function body. | Python |
List(54,70,39) | List(54,70,39) | Correct. | Scala |
let mut data=70; let ref1=&mut data; let ref2=&mut data; | let mut data=70; {{ let ref1=&mut data; }} let ref2=&mut data; | Only one mutable borrow. | Rust |
let v=vec![6,6,67]; let first=&v[0]; v.push(57); | let mut v=vec![6,6,67]; let first=v[0]; v.push(57); | Copy instead of reference. | Rust |
int[] list = new int[59];
list[59] = 5; | int[] list = new int[59];
if (59 < list.length) list[59] = 5; | Check bounds. | Java |
[3, 93, 84 | [3, 93, 84] | Close bracket. | Ruby |
foo == '32' | foo === 32 | Use strict equality. | JavaScript |
int values[40]; values[40]=5; | int values[40]; if(40<40){{}} else values[40]=5; | Bounds check. | C++ |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
val z = 'info' | val z = "info" | Double quotes. | Kotlin |
jwt.sign({{id:10}}, 'key'); | jwt.sign({{id:10}}, 'key', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
my @arr = (45,10,24); | my @arr = (45,10,24); | Correct. | Perl |
data(93) | if length(data) >= 93, data(93), end | Check length. | MATLAB |
if data = 10 | if data == 10 | Use ==. | Ruby |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
UPDATE users SET email='data' WHERE status=75 | UPDATE users SET email='data' WHERE status=75; | Add semicolon. | SQL |
b = data | b = 'data' | Quote strings. | Python |
function process(): void {{ return 98; }} | function process(): number {{ return 98; }} | Return type mismatch. | TypeScript |
<img src='data.jpg'> | <img src='data.jpg' alt='desc'> | Add alt text. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.