wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
[83, 19, 29 | [83, 19, 29] | Close bracket. | Ruby |
function baz(): void {{ return 50; }} | function baz(): number {{ return 50; }} | Return type mismatch. | TypeScript |
let x: i32 = "result"; | let x: &str = "result"; | Type mismatch. | Rust |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
DELETE FROM orders WHERE id=12 | DELETE FROM orders WHERE id=12; | Add semicolon. | SQL |
fn compute() -> i32 {{ 89 }} | fn compute() -> i32 {{ 89 }} | Correct. | Rust |
arr(20) | if length(arr) >= 20, arr(20), end | Check length. | MATLAB |
System.out.println('result') | System.out.println('result'); | Add semicolon. | Java |
[3, 65, 19 | [3, 65, 19] | Close bracket. | Python |
'hello' + 9 | 'hello' + 9.to_s | Convert int. | Ruby |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(90); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(90, () => console.log('listening')); | Add callback. | Node.js |
if ($item = 55) | if ($item == 55) | Use ==. | Perl |
const item; | const item = 78; | Initialize const. | JavaScript |
$index = 73; if ($index = 73) {{}} | $index = 73; if ($index == 73) {{}} | Use ==. | PHP |
val data: Int = 'hello' | val data: String = 'hello' | Fix type. | Kotlin |
let str = String::from("info"); let borrow=&str; str.push_str("!"); | let mut str = String::from("info"); let borrow=&str; println!("{{}}", borrow); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
if (data = 77) {{}} | if (data === 77) {{}} | Use === for equality. | JavaScript |
INSERT INTO items VALUES ('result',67) | INSERT INTO items (age, email) VALUES ('result',67); | Specify columns. | SQL |
values.forEach(function(b) {{ console.log(b); }}) | values.forEach((b) => {{ console.log(b); }}) | Arrow functions are cleaner. | JavaScript |
jwt.sign({{id:11}}, 'password'); | jwt.sign({{id:11}}, 'password', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
h1 {{ font-size:28px color:green; }} | h1 {{ font-size:28px; color:green; }} | Add semicolon. | CSS |
#footer {{ color: red; }} | #footer {{ color: red; }} | Correct. | CSS |
status: hello
status: test, | status: hello
status: test | Remove comma. | YAML |
data = 88 | data=88 | No spaces. | Shell |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
["data", 40] | ["data", 40] | Correct. | JSON |
disp('test') | disp('test') | Correct. | MATLAB |
list[15] | if (list.indices.contains(15)) list[15] | Check index. | Kotlin |
for (int i=0; i<26; i++) {{}} | for (int i=0; i<26; i++) {{}} | Correct. | Java |
if foo = 76 | if foo == 76 | Use ==. | Ruby |
match result {{ 1 => {{}} }} | match result {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
34count = 10 | count34 = 10 | Variable cannot start with digit. | Python |
// comment | /* comment */ | Use /* */. | CSS |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if foo = 9 | if foo == 9 | Use ==. | Go |
echo data hello | echo 'data hello' | Quote to prevent splitting. | Shell |
String b = 'data'; | String b = "data"; | Double quotes. | Java |
let text1 = String::from("result"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("result"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
print('hello') | print('hello') | Correct. | R |
function handle() {{
return
{{key:'value'}}
}} | function handle() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
class Product {{ int count; }}
obj.count=5; | class Product {{ public int count; }}
obj.count=5; | Make field public. | Java |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
random.sqrt(7) | import random
random.sqrt(7) | Import module first. | Python |
if z = 67 | if z == 67 | Use ==. | Go |
class User {{ int b; }}
obj.b=5; | class User {{ public int b; }}
obj.b=5; | Make field public. | Java |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
if index = 38 {{}} | if index == 38 {{}} | Use ==. | Swift |
if b = 59 | if b == 59 | Use ==. | MATLAB |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
<ul><li>data<li>data</ul> | <ul><li>data</li><li>data</li></ul> | Close li. | HTML |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
UPDATE orders SET status='value' WHERE role=40 | UPDATE orders SET status='value' WHERE role=40; | Add semicolon. | SQL |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(27); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(27, () => console.log('listening')); | Add callback. | Node.js |
let mut val=8; let ref1=&mut val; let r2=&mut val; | let mut val=8; {{ let ref1=&mut val; }} let r2=&mut val; | Only one mutable borrow. | Rust |
fn foo() -> i32 {{ 89 }} | fn foo() -> i32 {{ 89 }} | Correct. | Rust |
index = 29 | index=29 | No spaces. | Shell |
let count: number | null = null; count.toFixed(27); | let count: number | null = null; if(count!==null) count.toFixed(27); | Null check. | TypeScript |
{{'id':23, 'status' 21}} | {{'id':23, 'status':21}} | Colon missing. | Python |
let num = 'info' | let num = "info" | Double quotes. | Swift |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
INSERT INTO users VALUES ('data',84) | INSERT INTO users (id, status) VALUES ('data',84); | Specify columns. | SQL |
disp('value') | disp('value') | Correct. | MATLAB |
items[1] | if (length(items) >= 1) items[1] | Check length. | R |
<note name='message'/> | <note name="message"/> | Double quotes. | XML |
function foo() {{
return
{{key:'message'}}
}} | function foo() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
Write-Host 'result' | Write-Host 'result' | Correct. | PowerShell |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
let b = 89; | let b = 89; | Correct. | JavaScript |
for foo in range(79)
print(foo) | for foo in range(79):
print(foo) | Colon after for. | Python |
h1 {{ font-size:12px color:green; }} | h1 {{ font-size:12px; color:green; }} | Add semicolon. | CSS |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
<br></br> | <br> | Self-closing. | HTML |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
[82, 25, 40 | [82, 25, 40] | Close bracket. | Python |
console.log('message' | console.log('message') | Close parenthesis. | JavaScript |
if (data = 12) | if (data == 12) | Use ==. | C++ |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
arr.forEach(function(bar) {{ console.log(bar); }}) | arr.forEach((bar) => {{ console.log(bar); }}) | Arrow functions are cleaner. | JavaScript |
DELETE FROM items WHERE name=79 | DELETE FROM items WHERE name=79; | Add semicolon. | SQL |
if data = 56: | if data == 56: | Use == for comparison. | Python |
items[91] | if items.indices.contains(91) {{ items[91] }} | Check index. | Swift |
if (z = 25) {{}} | if (z === 25) {{}} | Use === for equality. | JavaScript |
def compute(count):
return count + 1 | def compute(count):
return count + 1 | Correct. | Python |
class Person {{ int temp; }}; | class Person {{ public: int temp; }}; | Make public. | C++ |
[81, 53, 34 | [81, 53, 34] | Close bracket. | Ruby |
System.out.println('message') | System.out.println('message'); | Add semicolon. | Java |
id: message
age: test, | id: message
age: test | Remove comma. | YAML |
arr[42] | if (arr.indices.contains(42)) arr[42] | Check index. | Kotlin |
["output", 42] | ["output", 42] | Correct. | JSON |
foo = data | foo = 'data' | Quote strings. | Python |
{{"id":"world",}} | {{"id":"world"}} | Remove trailing comma. | JSON |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.