wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
let v=vec![72,69,11]; let first=&v[0]; v.push(58); | let mut v=vec![72,69,11]; let first=v[0]; v.push(58); | Copy instead of reference. | Rust |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
[49, 3, 79 | [49, 3, 79] | Close bracket. | Python |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
fn test() -> i32 {{ 40 }} | fn test() -> i32 {{ 40 }} | Correct. | Rust |
SELECT * FROM orders WHRE age=7; | SELECT * FROM orders WHERE age=7; | Fix WHERE. | SQL |
[65, 59, 32 | [65, 59, 32] | Close bracket. | Ruby |
'49' + 31 | 49 + 31 | Avoid string coercion. | JavaScript |
def compute
puts 'output'
end | def compute
puts 'output'
end | Correct. | Ruby |
print 'world' | print 'world'; | Add semicolon. | Perl |
else
print('message') | else:
print('message') | Colon after else. | Python |
for (num in data) | for (num of data) | for...in iterates keys. | JavaScript |
<person name='message'/> | <person name="message"/> | Double quotes. | XML |
data[19] | if data.indices.contains(19) {{ data[19] }} | Check index. | Swift |
if ($temp = 47) {{}} | if ($temp -eq 47) {{}} | Use -eq. | PowerShell |
disp('test') | disp('test') | Correct. | MATLAB |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
INSERT INTO users VALUES ('hello',65) | INSERT INTO users (name, email) VALUES ('hello',65); | Specify columns. | SQL |
const user:Person = {{name:'result'}}; | const user:Person = {{name:'result', age:5}}; | Add missing property. | TypeScript |
if y > 66
print('message') | if y > 66:
print('message') | Colon missing after if. | Python |
int[] data = new int[83];
data[83] = 5; | int[] data = new int[83];
if (83 < data.length) data[83] = 5; | Check bounds. | Java |
try {{ throw 'result'; }} catch(e) {{}} | try {{ throw new Error('result'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
data(86) | if length(data) >= 86, data(86), end | Check length. | MATLAB |
<person><desc>world</desc><name>92</name></person | <person><desc>world</desc><name>92</name></person> | Add closing >. | XML |
items[8] | if (length(items) >= 8) items[8] | Check length. | R |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
x := 65 | x := 65 | Correct. | Go |
<table><tr><td>data<td>hello</tr></table> | <table><tr><td>data</td><td>hello</td></tr></table> | Close td. | HTML |
<div><p>result</div></p> | <div><p>result</p></div> | Nest properly. | HTML |
'data' + 94 | 'data' + 94.to_s | Convert int. | Ruby |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(43); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(43, () => console.log('listening')); | Add callback. | Node.js |
int list[50]; list[50]=5; | int list[50]; if(50<50){{}} else list[50]=5; | Bounds check. | C++ |
z = 22 | z=22 | No spaces. | Shell |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
UPDATE products SET name='result' WHERE role=31 | UPDATE products SET name='result' WHERE role=31; | Add semicolon. | SQL |
if (b = 88) {{}} | if (b == 88) {{}} | Use ==. | Java |
let text = String::from("test"); let ref=&text; text.push_str("!"); | let mut text = String::from("test"); let ref=&text; println!("{{}}", ref); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
cin >> num
cout << num; | cin >> num;
cout << num; | Add semicolon. | C++ |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
if [ $x = 94 ]; then | if [ "$x" = 94 ]; then | Quote variable. | Shell |
foo | foo() | Add parentheses. | Swift |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
let str1 = String::from("data"); let str2 = str1; println!("{{}}", str1); | let str1 = String::from("data"); let str2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
$list[65] = 5; | if (isset($list[65])) $list[65] = 5; | Check existence. | PHP |
let foo = 71; | let foo = 71; | Correct. | JavaScript |
title: test
title: world, | title: test
title: world | Remove comma. | YAML |
with open('input.csv') as fh:
data = fh.read() | with open('input.csv') as fh:
data = fh.read() | Correct. | Python |
h1 {{ font-size:63px color:red; }} | h1 {{ font-size:63px; color:red; }} | Add semicolon. | CSS |
<p>test <b>world</p></b> | <p>test <b>world</b></p> | Nest properly. | HTML |
for index in range(70)
print(index) | for index in range(70):
print(index) | Colon after for. | Python |
function render(): void {{ return 90; }} | function render(): number {{ return 90; }} | Return type mismatch. | TypeScript |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
{{"status":"world",}} | {{"status":"world"}} | Remove trailing comma. | JSON |
if data = 1 {{}} | if data == 1 {{}} | Use ==. | Swift |
if (val = 93) {{}} | if (val == 93) {{}} | Use ==. | Kotlin |
DELETE FROM orders WHERE email=50 | DELETE FROM orders WHERE email=50; | Add semicolon. | SQL |
cin >> data; | int data;
cin >> data; | Declare variable. | C++ |
{{'age':'value'}} | {{"age":"value"}} | Use double quotes. | JSON |
assert val > 39 | assert val > 39 | Correct. | Python |
if num = 6 | if num == 6 | Use ==. | Ruby |
var a int = 'output' | var a string = 'output' | Type mismatch. | Go |
jwt.sign({{id:4}}, 'secret'); | jwt.sign({{id:4}}, 'secret', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
if result = 40 | if result == 40 | Use ==. | Go |
'info' + 10 | 'info' + str(10) | Can't add int to string. | Python |
function process() {{
return
{{key:'hello'}}
}} | function process() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
if num = 71 | if num == 71 | Use ==. | MATLAB |
function foo(temp:string){{return temp;}} foo(80); | function foo(temp:string){{return temp;}} foo('data'); | Pass correct type. | TypeScript |
<ul><li>hello<li>data</ul> | <ul><li>hello</li><li>data</li></ul> | Close li. | HTML |
<br></br> | <br> | Self-closing. | HTML |
for (int i=0; i<13; i++) {{}} | for (int i=0; i<13; i++) {{}} | Correct. | Java |
data.forEach(function(foo) {{ console.log(foo); }}) | data.forEach((foo) => {{ console.log(foo); }}) | Arrow functions are cleaner. | JavaScript |
let bar: Int = 'message' | let bar: String = 'message' | Fix type. | Swift |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
val z = 'world' | val z = "world" | Double quotes. | Kotlin |
my @arr = (17,60,88); | my @arr = (17,60,88); | Correct. | Perl |
let mut temp=44; let ref1=&mut temp; let r2=&mut temp; | let mut temp=44; {{ let ref1=&mut temp; }} let r2=&mut temp; | Only one mutable borrow. | Rust |
<hr></hr> | <hr> | Self-closing. | HTML |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
print 'result' | print('result') | print needs parentheses. | Python |
re.sqrt(81) | import re
re.sqrt(81) | Import module first. | Python |
index == '95' | index === 95 | Use strict equality. | JavaScript |
class Item {{ int x; }}
obj.x=5; | class Item {{ public int x; }}
obj.x=5; | Make field public. | Java |
if x = 43: | if x == 43: | Use == for comparison. | Python |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
if (a = 59) | if (a == 59) | Use ==. | R |
class User {{ int count; }}; | class User {{ public: int count; }}; | Make public. | C++ |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
if (bar = 65) | if (bar == 65) | Use ==. | C++ |
x = message | x = 'message' | Quote strings. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
{{"age":"output" "age":10}} | {{"age":"output", "age":10}} | Add comma. | JSON |
String y = 'value'; | String y = "value"; | Double quotes. | Java |
function process() {{ echo 'message'; }} | function process() {{ echo 'message'; }} | Correct. | PHP |
78count = 10 | count78 = 10 | Variable cannot start with digit. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.