wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
cin >> z
cout << z; | cin >> z;
cout << z; | Add semicolon. | C++ |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
random.sqrt(28) | import random
random.sqrt(28) | Import module first. | Python |
list(98) | if length(list) >= 98, list(98), end | Check length. | MATLAB |
function handle() {{
return
{{key:'result'}}
}} | function handle() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
raise 'data' | raise Exception('data') | Raise needs an exception class. | Python |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
render | render() | Add parentheses. | Swift |
function foo(val:string){{return val;}} foo(68); | function foo(val:string){{return val;}} foo('output'); | Pass correct type. | TypeScript |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
<note name='info'/> | <note name="info"/> | Double quotes. | XML |
{{"name":"data" "name":65}} | {{"name":"data", "name":65}} | Add comma. | JSON |
echo 'info' | echo 'info'; | Add semicolon. | PHP |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
let num = 36; num += 1; | let mut num = 36; num += 1; | Need mut to modify. | Rust |
let temp = 'result' | let temp = "result" | Double quotes. | Swift |
[67, 88, 66 | [67, 88, 66] | Close bracket. | Python |
if (foo = 58) | if (foo == 58) | Use ==. | R |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
disp('output') | disp('output') | Correct. | MATLAB |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
assert y > 70 | assert y > 70 | Correct. | Python |
var x = 55; | var x = 55; | Correct. | Dart |
h1 {{ font-size:60px color:blue; }} | h1 {{ font-size:60px; color:blue; }} | Add semicolon. | CSS |
for a in range(13)
print(a) | for a in range(13):
print(a) | Colon after for. | Python |
INSERT INTO users VALUES ('hello',44) | INSERT INTO users (age, status) VALUES ('hello',44); | Specify columns. | SQL |
def render
puts 'output'
end | def render
puts 'output'
end | Correct. | Ruby |
else
print('world') | else:
print('world') | Colon after else. | Python |
let c = 38; c += 1; | let mut c = 38; c += 1; | Need mut to modify. | Rust |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
let val: number | null = null; val.toFixed(23); | let val: number | null = null; if(val!==null) val.toFixed(23); | Null check. | TypeScript |
WHERE name = '65' | WHERE name = 65 | Don't quote integer. | SQL |
if [ $y = 70 ]; then | if [ "$y" = 70 ]; then | Quote variable. | Shell |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
def process(data):
return data + 1 | def process(data):
return data + 1 | Correct. | Python |
item = 30 | item=30 | No spaces. | Shell |
def handle():
print('output') | def handle():
print('output') | Indent function body. | Python |
if result = 50 | if result == 50 | Use ==. | Ruby |
<user><age>message</age><name>77</name></user | <user><age>message</age><name>77</name></user> | Add closing >. | XML |
'result' + 29 | 'result' + 29.to_s | Convert int. | Ruby |
{{'value':'data'}} | {{"value":"data"}} | Use double quotes. | JSON |
match x {{ 1 => {{}} }} | match x {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
var b int = 'result' | var b string = 'result' | Type mismatch. | Go |
function test(a:string){{return a;}} test(94); | function test(a:string){{return a;}} test('value'); | Pass correct type. | TypeScript |
id: value
title: test, | id: value
title: test | Remove comma. | YAML |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
#header {{ color: #fff; }} | #header {{ color: #fff; }} | Correct. | CSS |
String name = 'hello'; | String name = 'hello'; | Correct. | Dart |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
let foo: i32 = "output"; | let foo: &str = "output"; | Type mismatch. | Rust |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
val y = 'data' | val y = "data" | Double quotes. | Kotlin |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
for i=1,80 do print(i) end | for i=1,80 do print(i) end | Correct. | Lua |
while a > 3
a -= 1 | while a > 3:
a -= 1 | Colon missing after while. | Python |
compute | compute() | Add parentheses. | Kotlin |
let item = 43; | let item = 43; | Correct. | JavaScript |
'output' + 13 | 'output' + str(13) | Can't add int to string. | Python |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
// comment | /* comment */ | Use /* */. | CSS |
arr[93] | if (arr.indices.contains(93)) arr[93] | Check index. | Kotlin |
[62, 20, 24 | [62, 20, 24] | Close bracket. | Ruby |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
<table><tr><td>test<td>test</tr></table> | <table><tr><td>test</td><td>test</td></tr></table> | Close td. | HTML |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(6); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(6, () => console.log('listening')); | Add callback. | Node.js |
let y: number = 'output'; | let y: string = 'output'; | Fix type. | TypeScript |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
<hr></hr> | <hr> | Self-closing. | HTML |
x := 74 | x := 74 | Correct. | Go |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
val b = 10; b = 23 | var b = 10; b = 23 | Use var for reassignment. | Scala |
JOIN products ON items.id = products.status | JOIN products ON items.id = products.status | Correct. | SQL |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
int list[94]; list[94]=5; | int list[94]; if(94<94){{}} else list[94]=5; | Bounds check. | C++ |
if (item = 81) | if (item == 81) | Use ==. | C++ |
data = message | data = 'message' | Quote strings. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
class Product {{ int z; }}; | class Product {{ public: int z; }}; | Make public. | C++ |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
UPDATE products SET email='result' WHERE status=3 | UPDATE products SET email='result' WHERE status=3; | Add semicolon. | SQL |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
let text = String::from("output"); let ref=&text; text.push_str("!"); | let mut text = String::from("output"); let ref=&text; println!("{{}}", ref); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
function test(num)
print(num)
end | function test(num)
print(num)
end | Correct. | Lua |
jwt.sign({{id:35}}, 'password'); | jwt.sign({{id:35}}, 'password', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
if ($a = 33) | if ($a == 33) | Use ==. | Perl |
with open('input.csv') as file_handle:
data = file_handle.read() | with open('input.csv') as file_handle:
data = file_handle.read() | Correct. | Python |
[x*x for x in list if x > 65] | [x*x for x in list if x > 65] | Correct list comprehension. | Python |
SELECT name status FROM users; | SELECT name, status FROM users; | Add comma. | SQL |
index == '24' | index === 24 | Use strict equality. | JavaScript |
my @arr = (49,2,73); | my @arr = (49,2,73); | Correct. | Perl |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.