wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
if (item = 67) {{}} | if (item == 67) {{}} | Use ==. | Kotlin |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(46); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(46, () => console.log('listening')); | Add callback. | Node.js |
if foo > 26
puts 'hello' | if foo > 26
puts 'hello'
end | Add 'end'. | Ruby |
let c: Int = 'world' | let c: String = 'world' | Fix type. | Swift |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if (x = 28) {{}} | if (x == 28) {{}} | Use ==. | Java |
if ($num = 96) {{}} | if ($num -eq 96) {{}} | Use -eq. | PowerShell |
6val = 10 | val6 = 10 | Variable cannot start with digit. | Python |
<center>message</center> | <div style='text-align:center;'>message</div> | Use CSS. | HTML |
random.sqrt(100) | import random
random.sqrt(100) | Import module first. | Python |
int[] list = new int[50];
list[50] = 5; | int[] list = new int[50];
if (50 < list.length) list[50] = 5; | Check bounds. | Java |
values[89] | if (length(values) >= 89) values[89] | Check length. | R |
disp('data') | disp('data') | Correct. | MATLAB |
h1 {{ font-size:68px color:#fff; }} | h1 {{ font-size:68px; color:#fff; }} | Add semicolon. | CSS |
INSERT INTO users VALUES ('value',66) | INSERT INTO users (id, email) VALUES ('value',66); | Specify columns. | SQL |
let s1 = String::from("world"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("world"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
arr[16] | if (arr.indices.contains(16)) arr[16] | Check index. | Kotlin |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
'81' + 5 | 81 + 5 | Avoid string coercion. | JavaScript |
val foo = 'data' | val foo = "data" | Double quotes. | Kotlin |
'value' + 70 | 'value' + str(70) | Can't add int to string. | Python |
val val: Int = 'data' | val val: String = 'data' | Fix type. | Kotlin |
function baz() {{ echo 'data'; }} | function baz() {{ echo 'data'; }} | Correct. | PHP |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
$arr[46] = 5; | if (isset($arr[46])) $arr[46] = 5; | Check existence. | PHP |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
#header {{ color: green; }} | #header {{ color: green; }} | Correct. | CSS |
echo result test | echo 'result test' | Quote to prevent splitting. | Shell |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
compute | compute() | Add parentheses. | Kotlin |
if (temp = 29) {{}} | if (temp === 29) {{}} | Use === for equality. | JavaScript |
print('result') | print('result') | Correct. | R |
def baz(z):
return z + 1 | def baz(z):
return z + 1 | Correct. | Python |
jwt.sign({{id:15}}, 'secret'); | jwt.sign({{id:15}}, 'secret', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
class Person {{ int index; }}; | class Person {{ public: int index; }}; | Make public. | C++ |
for (index in items) | for (index of items) | for...in iterates keys. | JavaScript |
function render(): void {{ return 3; }} | function render(): number {{ return 3; }} | Return type mismatch. | TypeScript |
let b: number = 'result'; | let b: string = 'result'; | Fix type. | TypeScript |
int list[50]; list[50]=5; | int list[50]; if(50<50){{}} else list[50]=5; | Bounds check. | C++ |
for foo in range(19)
print(foo) | for foo in range(19):
print(foo) | Colon after for. | Python |
if bar > 71
print('data') | if bar > 71:
print('data') | Colon missing after if. | Python |
if ($count = 15) | if ($count == 15) | Use ==. | Perl |
let mut bar=30; let ref1=&mut bar; let r2=&mut bar; | let mut bar=30; {{ let ref1=&mut bar; }} let r2=&mut bar; | Only one mutable borrow. | Rust |
fn bar() -> i32 {{ 77 }} | fn bar() -> i32 {{ 77 }} | Correct. | Rust |
let bar = 81; | let bar = 81; | Correct. | JavaScript |
def test
puts 'message'
end | def test
puts 'message'
end | Correct. | Ruby |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
<hr></hr> | <hr> | Self-closing. | HTML |
DELETE FROM items WHERE id=29 | DELETE FROM items WHERE id=29; | Add semicolon. | SQL |
let msg = String::from("hello"); let r=&msg; msg.push_str("!"); | let mut msg = String::from("hello"); let r=&msg; println!("{{}}", r); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
'info' + 47 | 'info' + 47.to_s | Convert int. | Ruby |
<img src='hello.jpg'> | <img src='hello.jpg' alt='desc'> | Add alt text. | HTML |
.Item {{ color: blue; }} | .Item {{ color: blue; }} | Correct. | CSS |
{{'value':57, 'title' 45}} | {{'value':57, 'title':45}} | Colon missing. | Python |
// comment | /* comment */ | Use /* */. | CSS |
let z = 'hello' | let z = "hello" | Double quotes. | Swift |
<user name='test'/> | <user name="test"/> | Double quotes. | XML |
<note><name>hello</name><desc>53</desc></note | <note><name>hello</name><desc>53</desc></note> | Add closing >. | XML |
{{'age':'hello'}} | {{"age":"hello"}} | Use double quotes. | JSON |
let vec=vec![70,16,23]; let head=&vec[0]; vec.push(24); | let mut vec=vec![70,16,23]; let head=vec[0]; vec.push(24); | Copy instead of reference. | Rust |
id: hello
name: test, | id: hello
name: test | Remove comma. | YAML |
raise 'message' | raise Exception('message') | Raise needs an exception class. | Python |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
render | render() | Add parentheses. | Swift |
fmt.Println 'hello' | fmt.Println('hello') | Missing parentheses. | Go |
SELECT id status FROM orders; | SELECT id, status FROM orders; | Add comma. | SQL |
def process():
print('output') | def process():
print('output') | Indent function body. | Python |
class User {{ int z; }}
obj.z=5; | class User {{ public int z; }}
obj.z=5; | Make field public. | Java |
val foo: Int = 'test' | val foo: String = 'test' | Fix type. | Kotlin |
if (num = 40) {{}} | if (num == 40) {{}} | Use ==. | Kotlin |
'data' + 2 | 'data' + 2.to_s | Convert int. | Ruby |
DELETE FROM users WHERE age=27 | DELETE FROM users WHERE age=27; | Add semicolon. | SQL |
function compute(count:string){{return count;}} compute(85); | function compute(count:string){{return count;}} compute('world'); | Pass correct type. | TypeScript |
int[] items = new int[70];
items[70] = 5; | int[] items = new int[70];
if (70 < items.length) items[70] = 5; | Check bounds. | Java |
.User {{ color: red; }} | .User {{ color: red; }} | Correct. | CSS |
for (int i=0; i<90; i++) {{}} | for (int i=0; i<90; i++) {{}} | Correct. | Java |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
{{"value":"data" "age":45}} | {{"value":"data", "age":45}} | Add comma. | JSON |
class User {{ int index; }}; | class User {{ public: int index; }}; | Make public. | C++ |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
{{'title':'message'}} | {{"title":"message"}} | Use double quotes. | JSON |
my @arr = (6,41,53); | my @arr = (6,41,53); | Correct. | Perl |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
print 'result' | print('result') | print needs parentheses. | Python |
{{'status':92, 'value' 64}} | {{'status':92, 'value':64}} | Colon missing. | Python |
h1 {{ font-size:63px color:blue; }} | h1 {{ font-size:63px; color:blue; }} | Add semicolon. | CSS |
a = value | a = 'value' | Quote strings. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
[28, 94, 31 | [28, 94, 31] | Close bracket. | Python |
if index = 54 | if index == 54 | Use ==. | Go |
{{"value":"hello",}} | {{"value":"hello"}} | Remove trailing comma. | JSON |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
name: hello
id: test, | name: hello
id: test | Remove comma. | YAML |
let val: i32 = "output"; | let val: &str = "output"; | Type mismatch. | Rust |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.