wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let s1 = String::from("world"); let str2 = s1; println!("{{}}", s1); | let s1 = String::from("world"); let str2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
process | process() | Add parentheses. | Swift |
jwt.sign({{id:90}}, 'secret'); | jwt.sign({{id:90}}, 'secret', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
assert b > 69 | assert b > 69 | Correct. | Python |
if ($data = 46) {{}} | if ($data -eq 46) {{}} | Use -eq. | PowerShell |
my @arr = (2,37,21); | my @arr = (2,37,21); | Correct. | Perl |
const x; | const x = 31; | Initialize const. | JavaScript |
var val int = 'message' | var val string = 'message' | Type mismatch. | Go |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
compute | compute() | Add parentheses. | Kotlin |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
<entry name='message'/> | <entry name="message"/> | Double quotes. | XML |
if temp = 29 then
print('data')
end | if temp == 29 then
print('data')
end | Use ==. | Lua |
<p>world <b>hello</p></b> | <p>world <b>hello</b></p> | Nest properly. | HTML |
if ($item = 90) | if ($item == 90) | Use ==. | Perl |
num = 26 | num=26 | No spaces. | Shell |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
let c = 92; c += 1; | let mut c = 92; c += 1; | Need mut to modify. | Rust |
<div><p>world</div></p> | <div><p>world</p></div> | Nest properly. | HTML |
if (item = 40) | if (item == 40) | Use ==. | C++ |
[33, 32, 75 | [33, 32, 75] | Close bracket. | Ruby |
name: result
age: 93 | name: result
age: 93 | Correct. | YAML |
if (b = 24) | if (b == 24) | Use ==. | R |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
let mut z=61; let r1=&mut z; let ref2=&mut z; | let mut z=61; {{ let r1=&mut z; }} let ref2=&mut z; | Only one mutable borrow. | Rust |
yield result | yield result | Correct yield. | Python |
[79, 9, 35 | [79, 9, 35] | Close bracket. | Python |
$data[85] | if ($data.Count -gt 85) {{ $data[85] }} | Check bounds. | PowerShell |
{{'value':14, 'id' 67}} | {{'value':14, 'id':67}} | Colon missing. | Python |
age: message
age: test, | age: message
age: test | Remove comma. | YAML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
WHERE age = '15' | WHERE age = 15 | Don't quote integer. | SQL |
JOIN orders ON orders.id = orders.name | JOIN orders ON orders.id = orders.name | Correct. | SQL |
int values[70]; values[70]=5; | int values[70]; if(70<70){{}} else values[70]=5; | Bounds check. | C++ |
for i=1,48 do print(i) end | for i=1,48 do print(i) end | Correct. | Lua |
SELECT age role FROM orders; | SELECT age, role FROM orders; | Add comma. | SQL |
object Product {{ def main(args: Array[String]) = println("data") }} | object Product {{ def main(args: Array[String]): Unit = println("data") }} | Add return type Unit. | Scala |
INSERT INTO users VALUES ('output',77) | INSERT INTO users (id, status) VALUES ('output',77); | Specify columns. | SQL |
["data", 1] | ["data", 1] | Correct. | JSON |
var x int | var x int | Correct. | Go |
with open('config.json') as fp:
data = fp.read() | with open('config.json') as fp:
data = fp.read() | Correct. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
function test(): void {{ return 81; }} | function test(): number {{ return 81; }} | Return type mismatch. | TypeScript |
SELECT * FROM users WHRE name=6; | SELECT * FROM users WHERE name=6; | Fix WHERE. | SQL |
class Product {{ int b; }}
obj.b=5; | class Product {{ public int b; }}
obj.b=5; | Make field public. | Java |
let a = 41; let a = 39; | let a = 41; a = 39; | Duplicate declaration. | JavaScript |
// comment | /* comment */ | Use /* */. | CSS |
<person age=45> | <person age="45"> | Quote attribute. | XML |
const bar = 95; bar = 70; | let bar = 95; bar = 70; | Cannot reassign const. | JavaScript |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
'76' + 28 | 76 + 28 | Avoid string coercion. | JavaScript |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if (val = 48) {{}} | if (val == 48) {{}} | Use ==. | Java |
for (int i=0; i<73; i++) {{}} | for (int i=0; i<73; i++) {{}} | Correct. | Java |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
item = output | item = 'output' | Quote strings. | Python |
#content {{ color: red; }} | #content {{ color: red; }} | Correct. | CSS |
println('info') | println("info") | Double quotes. | Scala |
if (x = 44) {{}} | if (x == 44) {{}} | Use ==. | Kotlin |
function compute() {{
return
{{key:'data'}}
}} | function compute() {{
return {{key:'data'}};
}} | Return object on same line. | JavaScript |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
val z: Int = 'result' | val z: String = 'result' | Fix type. | Kotlin |
num == '26' | num === 26 | Use strict equality. | JavaScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
y > 55 & a < 40 | y > 55 and a < 40 | Use 'and' not '&'. | Python |
switch(z){{ case 97: break; }} | switch(z){{ case 97: break; default: break; }} | Add default case. | Java |
<table><tr><td>test<td>world</tr></table> | <table><tr><td>test</td><td>world</td></tr></table> | Close td. | HTML |
DELETE FROM orders WHERE status=71 | DELETE FROM orders WHERE status=71; | Add semicolon. | SQL |
int num = 'data'; | String num = 'data'; | Type mismatch. | Dart |
38y = 10 | y38 = 10 | Variable cannot start with digit. | Python |
val temp = 'test' | val temp = "test" | Double quotes. | Kotlin |
void main() {{ print('world') }} | void main() {{ print('world'); }} | Add semicolon. | Dart |
echo 'output' | echo 'output'; | Add semicolon. | PHP |
if x = 4 | if x == 4 | Use ==. | MATLAB |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
{ "name": "data" } | { "name": "data" } | Correct. | JSON |
function baz(index:string){{return index;}} baz(10); | function baz(index:string){{return index;}} baz('value'); | Pass correct type. | TypeScript |
let num: number | null = null; num.toFixed(7); | let num: number | null = null; if(num!==null) num.toFixed(7); | Null check. | TypeScript |
let vec=vec![49,70,14]; let head=&vec[0]; vec.push(69); | let mut vec=vec![49,70,14]; let head=vec[0]; vec.push(69); | Copy instead of reference. | Rust |
for num in range(70)
print(num) | for num in range(70):
print(num) | Colon after for. | Python |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
h1 {{ font-size:12px color:#fff; }} | h1 {{ font-size:12px; color:#fff; }} | Add semicolon. | CSS |
let result = 31; | let result = 31; | Correct. | JavaScript |
<hr></hr> | <hr> | Self-closing. | HTML |
list.forEach(function(val) {{ console.log(val); }}) | list.forEach((val) => {{ console.log(val); }}) | Arrow functions are cleaner. | JavaScript |
if [ $bar = 1 ]; then | if [ "$bar" = 1 ]; then | Quote variable. | Shell |
else
print('info') | else:
print('info') | Colon after else. | Python |
function bar() {{ echo 'data'; }} | function bar() {{ echo 'data'; }} | Correct. | PHP |
String name = 'test'; | String name = 'test'; | Correct. | Dart |
val c: Int = 'data' | val c: String = 'data' | Fix type. | Kotlin |
function bar(val:string){{return val;}} bar(38); | function bar(val:string){{return val;}} bar('data'); | Pass correct type. | TypeScript |
let index = 61; | let index = 61; | Correct. | JavaScript |
local z = 12 | local z = 12 | Correct. | Lua |
print('message') | print('message') | Correct. | R |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.