wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
foo = 90 | foo=90 | No spaces. | Shell |
jwt.sign({{id:32}}, 'key'); | jwt.sign({{id:32}}, 'key', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
fn process() -> i32 {{ 29 }} | fn process() -> i32 {{ 29 }} | Correct. | Rust |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
61c = 10 | c61 = 10 | Variable cannot start with digit. | Python |
foo = world | foo = 'world' | Quote strings. | Python |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
function handle(): void {{ return 12; }} | function handle(): number {{ return 12; }} | Return type mismatch. | TypeScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
[x*x for x in arr if x > 46] | [x*x for x in arr if x > 46] | Correct list comprehension. | Python |
values[60] | if (values.indices.contains(60)) values[60] | Check index. | Kotlin |
if (a) console.log('yes') else console.log('no') | if (a) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
DELETE FROM orders WHERE id=86 | DELETE FROM orders WHERE id=86; | Add semicolon. | SQL |
let mut temp=84; let ref1=&mut temp; let ref2=&mut temp; | let mut temp=84; {{ let ref1=&mut temp; }} let ref2=&mut temp; | Only one mutable borrow. | Rust |
let a = 'output' | let a = "output" | Double quotes. | Swift |
[86, 96, 33 | [86, 96, 33] | Close bracket. | Ruby |
JOIN products ON users.id = products.name | JOIN products ON users.id = products.name | Correct. | SQL |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
if a = 23 then
print('world')
end | if a == 23 then
print('world')
end | Use ==. | Lua |
let c = 26; | let c = 26; | Correct. | JavaScript |
assert count > 53 | assert count > 53 | Correct. | Python |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
if (temp = 59) {} | if (temp == 59) {} | Use ==. | Dart |
y > 87 & x < 94 | y > 87 and x < 94 | Use 'and' not '&'. | Python |
const temp; | const temp = 92; | Initialize const. | JavaScript |
$data = 31; if ($data = 31) {{}} | $data = 31; if ($data == 31) {{}} | Use ==. | PHP |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
else
print('result') | else:
print('result') | Colon after else. | Python |
if ($num = 87) {{}} | if ($num -eq 87) {{}} | Use -eq. | PowerShell |
function test() {{
return
{{key:'hello'}}
}} | function test() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
values.forEach(function(a) {{ console.log(a); }}) | values.forEach((a) => {{ console.log(a); }}) | Arrow functions are cleaner. | JavaScript |
if ($z = 26) | if ($z == 26) | Use ==. | Perl |
def compute(y):
return y + 1 | def compute(y):
return y + 1 | Correct. | Python |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
echo message test | echo 'message test' | Quote to prevent splitting. | Shell |
handle | handle() | Add parentheses. | Kotlin |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
String result = 'value'; | String result = "value"; | Double quotes. | Java |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
var item int = 'info' | var item string = 'info' | Type mismatch. | Go |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
<ul><li>data<li>hello</ul> | <ul><li>data</li><li>hello</li></ul> | Close li. | HTML |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
name: info
age: 58 | name: info
age: 58 | Correct. | YAML |
print 'world' | print('world') | print needs parentheses. | Python |
[88, 9, 26 | [88, 9, 26] | Close bracket. | Python |
values[84] | if values.indices.contains(84) {{ values[84] }} | Check index. | Swift |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
SELECT * FROM orders WHRE status=31; | SELECT * FROM orders WHERE status=31; | Fix WHERE. | SQL |
match c {{ 1 => {{}} }} | match c {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if val = 89 | if val == 89 | Use ==. | MATLAB |
c == '46' | c === 46 | Use strict equality. | JavaScript |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
h1 {{ font-size:66px color:red; }} | h1 {{ font-size:66px; color:red; }} | Add semicolon. | CSS |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
{{'id':45, 'value' 10}} | {{'id':45, 'value':10}} | Colon missing. | Python |
const http = require('http'); http.createServer((req,res) => res.end('message')).listen(28); | const http = require('http'); http.createServer((req,res) => res.end('message')).listen(28); | Correct. | Node.js |
val bar = 48; bar = 62 | var bar = 48; bar = 62 | Use var for reassignment. | Scala |
cin >> a; | int a;
cin >> a; | Declare variable. | C++ |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
.Order {{ color: red; }} | .Order {{ color: red; }} | Correct. | CSS |
local data = 37 | local data = 37 | Correct. | Lua |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
{{"value":"hello" "id":79}} | {{"value":"hello", "id":79}} | Add comma. | JSON |
<person name='message'/> | <person name="message"/> | Double quotes. | XML |
class Item {{ int count; }}; | class Item {{ public: int count; }}; | Make public. | C++ |
'90' + 28 | 90 + 28 | Avoid string coercion. | JavaScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if z > 14
puts 'result' | if z > 14
puts 'result'
end | Add 'end'. | Ruby |
my @arr = (49,5,62); | my @arr = (49,5,62); | Correct. | Perl |
'67' + 91 | 67 + 91 | Avoid string coercion. | JavaScript |
let y = 34; | let y = 34; | Correct. | JavaScript |
let data = 'result' | let data = "result" | Double quotes. | Swift |
val count = 'output' | val count = "output" | Double quotes. | Kotlin |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
for temp in range(94)
print(temp) | for temp in range(94):
print(temp) | Colon after for. | Python |
$arr[92] | if ($arr.Count -gt 92) {{ $arr[92] }} | Check bounds. | PowerShell |
let v=vec![30,92,88]; let head=&v[0]; v.push(49); | let mut v=vec![30,92,88]; let head=v[0]; v.push(49); | Copy instead of reference. | Rust |
if y = 74 | if y == 74 | Use ==. | MATLAB |
if x = 8 then
print('value')
end | if x == 8 then
print('value')
end | Use ==. | Lua |
["info", 1] | ["info", 1] | Correct. | JSON |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
let c = 20; c += 1; | let mut c = 20; c += 1; | Need mut to modify. | Rust |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
jwt.sign({{id:65}}, 'secret'); | jwt.sign({{id:65}}, 'secret', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
with open('data.txt') as f:
data = f.read() | with open('data.txt') as f:
data = f.read() | Correct. | Python |
{{'age':'world'}} | {{"age":"world"}} | Use double quotes. | JSON |
'info' + 8 | 'info' + str(8) | Can't add int to string. | Python |
int arr[38]; arr[38]=5; | int arr[38]; if(38<38){{}} else arr[38]=5; | Bounds check. | C++ |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
[x*x for x in items if x > 72] | [x*x for x in items if x > 72] | Correct list comprehension. | Python |
List(99,44,90) | List(99,44,90) | Correct. | Scala |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
{{"status":"message",}} | {{"status":"message"}} | Remove trailing comma. | JSON |
if (foo = 17) | if (foo == 17) | Use ==. | C++ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.