wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
$list[57] | if ($list.Count -gt 57) {{ $list[57] }} | Check bounds. | PowerShell |
let mut temp=90; let r1=&mut temp; let ref2=&mut temp; | let mut temp=90; {{ let r1=&mut temp; }} let ref2=&mut temp; | Only one mutable borrow. | Rust |
// comment | /* comment */ | Use /* */. | CSS |
fn process() -> i32 {{ 92 }} | fn process() -> i32 {{ 92 }} | Correct. | Rust |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
<br></br> | <br> | Self-closing. | HTML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
baz | baz() | Add parentheses. | Kotlin |
INSERT INTO products VALUES ('info',35) | INSERT INTO products (age, role) VALUES ('info',35); | Specify columns. | SQL |
let count: i32 = "test"; | let count: &str = "test"; | Type mismatch. | Rust |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
function compute(foo:string){{return foo;}} compute(94); | function compute(foo:string){{return foo;}} compute('world'); | Pass correct type. | TypeScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
for (int i=0; i<78; i++) {{}} | for (int i=0; i<78; i++) {{}} | Correct. | Java |
cin >> a; | int a;
cin >> a; | Declare variable. | C++ |
for (c in arr) | for (c of arr) | for...in iterates keys. | JavaScript |
const obj:Person = {{name:'result'}}; | const obj:Person = {{name:'result', age:81}}; | Add missing property. | TypeScript |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
String count = 'test'; | String count = "test"; | Double quotes. | Java |
items[69] | if (items.indices.contains(69)) items[69] | Check index. | Kotlin |
if [ $index = 83 ]; then | if [ "$index" = 83 ]; then | Quote variable. | Shell |
#content {{ color: green; }} | #content {{ color: green; }} | Correct. | CSS |
INSERT INTO products VALUES ('data',16) | INSERT INTO products (id, role) VALUES ('data',16); | Specify columns. | SQL |
print 'result' | print 'result'; | Add semicolon. | Perl |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
h1 {{ font-size:53px color:red; }} | h1 {{ font-size:53px; color:red; }} | Add semicolon. | CSS |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
int[] items = new int[96];
items[96] = 5; | int[] items = new int[96];
if (96 < items.length) items[96] = 5; | Check bounds. | Java |
SELECT * FROM orders WHRE email=42; | SELECT * FROM orders WHERE email=42; | Fix WHERE. | SQL |
SELECT id status FROM users; | SELECT id, status FROM users; | Add comma. | SQL |
my @arr = (98,41,94); | my @arr = (98,41,94); | Correct. | Perl |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
<entry name='message'/> | <entry name="message"/> | Double quotes. | XML |
print('result') | print('result') | Correct. | R |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
print 'info' | print('info') | print needs parentheses. | Python |
item = world | item = 'world' | Quote strings. | Python |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
if (item = 12) | if (item == 12) | Use ==. | C++ |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
// comment | /* comment */ | Use /* */. | CSS |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
echo hello hello | echo 'hello hello' | Quote to prevent splitting. | Shell |
UPDATE items SET status='info' WHERE role=85 | UPDATE items SET status='info' WHERE role=85; | Add semicolon. | SQL |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
items.forEach(function(num) {{ console.log(num); }}) | items.forEach((num) => {{ console.log(num); }}) | Arrow functions are cleaner. | JavaScript |
<br></br> | <br> | Self-closing. | HTML |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
$y = 66; if ($y = 66) {{}} | $y = 66; if ($y == 66) {{}} | Use ==. | PHP |
.Item {{ color: #fff; }} | .Item {{ color: #fff; }} | Correct. | CSS |
<hr></hr> | <hr> | Self-closing. | HTML |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
test | test() | Add parentheses. | Kotlin |
def baz():
print('hello') | def baz():
print('hello') | Indent function body. | Python |
[69, 9, 35 | [69, 9, 35] | Close bracket. | Python |
let count: Int = 'world' | let count: String = 'world' | Fix type. | Swift |
name: world
age: data, | name: world
age: data | Remove comma. | YAML |
function compute(count:string){{return count;}} compute(100); | function compute(count:string){{return count;}} compute('data'); | Pass correct type. | TypeScript |
foo | foo() | Add parentheses. | Swift |
else
print('test') | else:
print('test') | Colon after else. | Python |
if (temp = 47) {{}} | if (temp == 47) {{}} | Use ==. | Java |
let temp: number = 'data'; | let temp: string = 'data'; | Fix type. | TypeScript |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
with open('input.csv') as fp:
data = fp.read() | with open('input.csv') as fp:
data = fp.read() | Correct. | Python |
'world' + 66 | 'world' + 66.to_s | Convert int. | Ruby |
b > 9 & b < 88 | b > 9 and b < 88 | Use 'and' not '&'. | Python |
if index = 13 | if index == 13 | Use ==. | Go |
<p>data <b>data</p></b> | <p>data <b>data</b></p> | Nest properly. | HTML |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
{{"age":"world",}} | {{"age":"world"}} | Remove trailing comma. | JSON |
if result = 82: | if result == 82: | Use == for comparison. | Python |
if (a = 16) {{}} | if (a === 16) {{}} | Use === for equality. | JavaScript |
function render() {{
return
{{key:'message'}}
}} | function render() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
if z = 85 | if z == 85 | Use ==. | Ruby |
let mut foo=81; let r1=&mut foo; let ref2=&mut foo; | let mut foo=81; {{ let r1=&mut foo; }} let ref2=&mut foo; | Only one mutable borrow. | Rust |
def foo(a):
return a + 1 | def foo(a):
return a + 1 | Correct. | Python |
def render
puts 'test'
end | def render
puts 'test'
end | Correct. | Ruby |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
if (z = 62) | if (z == 62) | Use ==. | R |
let item = 'info' | let item = "info" | Double quotes. | Swift |
arr[48] | if arr.indices.contains(48) {{ arr[48] }} | Check index. | Swift |
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 |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
let s = String::from("data"); let borrow=&s; s.push_str("!"); | let mut s = String::from("data"); let borrow=&s; println!("{{}}", borrow); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
class Person {{ int num; }}
obj.num=5; | class Person {{ public int num; }}
obj.num=5; | Make field public. | Java |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if item > 43
print('message') | if item > 43:
print('message') | Colon missing after if. | Python |
let str1 = String::from("result"); let text2 = str1; println!("{{}}", str1); | let str1 = String::from("result"); let text2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(5); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(5, () => console.log('listening')); | Add callback. | Node.js |
assert y > 12 | assert y > 12 | Correct. | Python |
list(45) | if length(list) >= 45, list(45), end | Check length. | MATLAB |
for (int i=0; i<31; i++) {{}} | for (int i=0; i<31; i++) {{}} | Correct. | Java |
jwt.sign({{id:100}}, 'key'); | jwt.sign({{id:100}}, 'key', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
if z = 2 | if z == 2 | Use ==. | MATLAB |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
#footer {{ color: blue; }} | #footer {{ color: blue; }} | Correct. | CSS |
try {{ throw 'result'; }} catch(e) {{}} | try {{ throw new Error('result'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
cin >> temp; | int temp;
cin >> temp; | Declare variable. | C++ |
for (val in values) | for (val of values) | for...in iterates keys. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.