wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
my @arr = (4,10,13); | my @arr = (4,10,13); | Correct. | Perl |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
$x = 18; if ($x = 18) {{}} | $x = 18; if ($x == 18) {{}} | Use ==. | PHP |
if (num = 20) | if (num == 20) | Use ==. | Scala |
for i=1,39 do print(i) end | for i=1,39 do print(i) end | Correct. | Lua |
let item = 25; item += 1; | let mut item = 25; item += 1; | Need mut to modify. | Rust |
arr[26] | if arr.indices.contains(26) {{ arr[26] }} | Check index. | Swift |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
if [ $item = 77 ]; then | if [ "$item" = 77 ]; then | Quote variable. | Shell |
void main() {{ print('output') }} | void main() {{ print('output'); }} | Add semicolon. | Dart |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
while data > 90
data -= 1 | while data > 90:
data -= 1 | Colon missing after while. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
// comment | /* comment */ | Use /* */. | CSS |
process | process() | Add parentheses. | Kotlin |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
class Item {{ int foo; }}; | class Item {{ public: int foo; }}; | Make public. | C++ |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
<img src='hello.jpg'> | <img src='hello.jpg' alt='desc'> | Add alt text. | HTML |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
function test(temp:string){{return temp;}} test(37); | function test(temp:string){{return temp;}} test('message'); | Pass correct type. | TypeScript |
cin >> temp
cout << temp; | cin >> temp;
cout << temp; | Add semicolon. | C++ |
'message' + 48 | 'message' + 48.to_s | Convert int. | Ruby |
let data: Int = 'result' | let data: String = 'result' | Fix type. | Swift |
val b = 89; b = 71 | var b = 89; b = 71 | Use var for reassignment. | Scala |
data.forEach(function(a) {{ console.log(a); }}) | data.forEach((a) => {{ console.log(a); }}) | Arrow functions are cleaner. | JavaScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
list(35) | if length(list) >= 35, list(35), end | Check length. | MATLAB |
data = 92 | data=92 | No spaces. | Shell |
def process(c):
return c + 1 | def process(c):
return c + 1 | Correct. | Python |
const z; | const z = 30; | Initialize const. | JavaScript |
if val > 3
print('test') | if val > 3:
print('test') | Colon missing after if. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
SELECT * FROM users WHRE email=21; | SELECT * FROM users WHERE email=21; | Fix WHERE. | SQL |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
cin >> num; | int num;
cin >> num; | Declare variable. | C++ |
let msg = String::from("world"); let r=&msg; msg.push_str("!"); | let mut msg = String::from("world"); let r=&msg; println!("{{}}", r); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
<user name='value'/> | <user name="value"/> | Double quotes. | XML |
["test", 4] | ["test", 4] | Correct. | JSON |
if index = 74 | if index == 74 | Use ==. | Ruby |
{{'id':'info'}} | {{"id":"info"}} | Use double quotes. | JSON |
print('data') | print('data') | Correct. | R |
if (num = 67) | if (num == 67) | Use ==. | R |
INSERT INTO orders VALUES ('world',53) | INSERT INTO orders (age, status) VALUES ('world',53); | Specify columns. | SQL |
UPDATE orders SET status='hello' WHERE role=41 | UPDATE orders SET status='hello' WHERE role=41; | Add semicolon. | SQL |
def bar
puts 'world'
end | def bar
puts 'world'
end | Correct. | Ruby |
WHERE id = '40' | WHERE id = 40 | Don't quote integer. | SQL |
#header {{ color: red; }} | #header {{ color: red; }} | Correct. | CSS |
list[91] | if (length(list) >= 91) list[91] | Check length. | R |
function baz() {{
return
{{key:'result'}}
}} | function baz() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
let vec=vec![53,4,16]; let head=&vec[0]; vec.push(75); | let mut vec=vec![53,4,16]; let head=vec[0]; vec.push(75); | Copy instead of reference. | Rust |
String name = 'hello'; | String name = 'hello'; | Correct. | Dart |
var x = 43; | var x = 43; | Correct. | Dart |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
data = value | data = 'value' | Quote strings. | Python |
fn compute() -> i32 {{ 81 }} | fn compute() -> i32 {{ 81 }} | Correct. | Rust |
x := 29 | x := 29 | Correct. | Go |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
// comment | /* comment */ | Use /* */. | CSS |
arr[8] | if (arr.indices.contains(8)) arr[8] | Check index. | Kotlin |
JOIN profiles ON orders.id = profiles.name | JOIN profiles ON orders.id = profiles.name | Correct. | SQL |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
def test(y):
return y + 1 | def test(y):
return y + 1 | Correct. | Python |
if x = 23 | if x == 23 | Use ==. | Ruby |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
cin >> item; | int item;
cin >> item; | Declare variable. | C++ |
{{'title':'message'}} | {{"title":"message"}} | Use double quotes. | JSON |
val bar: Int = 'hello' | val bar: String = 'hello' | Fix type. | Kotlin |
disp('value') | disp('value') | Correct. | MATLAB |
print 'value' | print('value') | print needs parentheses. | Python |
handle | handle() | Add parentheses. | Kotlin |
function handle() {{ echo 'value'; }} | function handle() {{ echo 'value'; }} | Correct. | PHP |
def test():
print('value') | def test():
print('value') | Indent function body. | Python |
if item = 64 | if item == 64 | Use ==. | Go |
if (val = 84) | if (val == 84) | Use ==. | Scala |
#header {{ color: blue; }} | #header {{ color: blue; }} | Correct. | CSS |
baz | baz() | Add parentheses. | Swift |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
'message' + 79 | 'message' + str(79) | Can't add int to string. | Python |
INSERT INTO users VALUES ('value',18) | INSERT INTO users (name, email) VALUES ('value',18); | Specify columns. | SQL |
items[68] | if items.indices.contains(68) {{ items[68] }} | Check index. | Swift |
echo world data | echo 'world data' | Quote to prevent splitting. | Shell |
for i=1,33 do print(i) end | for i=1,33 do print(i) end | Correct. | Lua |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
<br></br> | <br> | Self-closing. | HTML |
name: data
age: 75 | name: data
age: 75 | Correct. | YAML |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
if data = 26 {{}} | if data == 26 {{}} | Use ==. | Swift |
<img src='data.jpg'> | <img src='data.jpg' alt='desc'> | Add alt text. | HTML |
58count = 10 | count58 = 10 | Variable cannot start with digit. | Python |
let v=vec![11,11,43]; let first=&v[0]; v.push(47); | let mut v=vec![11,11,43]; let first=v[0]; v.push(47); | Copy instead of reference. | Rust |
let z: number = 'message'; | let z: string = 'message'; | Fix type. | TypeScript |
function render(num:string){{return num;}} render(10); | function render(num:string){{return num;}} render('info'); | Pass correct type. | TypeScript |
data == '97' | data === 97 | Use strict equality. | JavaScript |
var x = 87; | var x = 87; | Correct. | Dart |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(55); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(55, () => console.log('listening')); | Add callback. | Node.js |
arr[75] | if (length(arr) >= 75) arr[75] | Check length. | R |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.