wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if (num = 97) {{}} | if (num == 97) {{}} | Use ==. | Java |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(3); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(3, () => console.log('listening')); | Add callback. | Node.js |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
$list[15] = 5; | if (isset($list[15])) $list[15] = 5; | Check existence. | PHP |
var x = 78; | var x = 78; | Correct. | Dart |
my @arr = (50,10,11); | my @arr = (50,10,11); | Correct. | Perl |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
function test() {{ echo 'world'; }} | function test() {{ echo 'world'; }} | Correct. | PHP |
[28, 37, 9 | [28, 37, 9] | Close bracket. | Ruby |
var x int | var x int | Correct. | Go |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
[x*x for x in data if x > 50] | [x*x for x in data if x > 50] | Correct list comprehension. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
let z: number | null = null; z.toFixed(44); | let z: number | null = null; if(z!==null) z.toFixed(44); | Null check. | TypeScript |
x := 26 | x := 26 | Correct. | Go |
cin >> item
cout << item; | cin >> item;
cout << item; | Add semicolon. | C++ |
arr[12] | if (length(arr) >= 12) arr[12] | Check length. | R |
[37, 70, 26 | [37, 70, 26] | Close bracket. | Python |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
<person age=38> | <person age="38"> | Quote attribute. | XML |
bar = world | bar = 'world' | Quote strings. | Python |
if ($result = 96) {{}} | if ($result -eq 96) {{}} | Use -eq. | PowerShell |
math.sqrt(81) | import math
math.sqrt(81) | Import module first. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
for i=1,12 do print(i) end | for i=1,12 do print(i) end | Correct. | Lua |
JOIN orders ON items.id = orders.id | JOIN orders ON items.id = orders.id | Correct. | SQL |
let text = String::from("test"); let r=&text; text.push_str("!"); | let mut text = String::from("test"); let r=&text; println!("{{}}", r); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
$items[16] | if ($items.Count -gt 16) {{ $items[16] }} | Check bounds. | PowerShell |
let mut b=40; let ref1=&mut b; let r2=&mut b; | let mut b=40; {{ let ref1=&mut b; }} let r2=&mut b; | Only one mutable borrow. | Rust |
var x int = 'result' | var x string = 'result' | Type mismatch. | Go |
.Person {{ color: red; }} | .Person {{ color: red; }} | Correct. | CSS |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
let temp: i32 = "test"; | let temp: &str = "test"; | Type mismatch. | Rust |
if item = 46 | if item == 46 | Use ==. | Go |
let index: number = 'test'; | let index: string = 'test'; | Fix type. | TypeScript |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
render | render() | Add parentheses. | Swift |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
if foo = 74 {{}} | if foo == 74 {{}} | Use ==. | Swift |
data.forEach(function(index) {{ console.log(index); }}) | data.forEach((index) => {{ console.log(index); }}) | Arrow functions are cleaner. | JavaScript |
z > 75 & b < 61 | z > 75 and b < 61 | Use 'and' not '&'. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
'10' + 87 | 10 + 87 | Avoid string coercion. | JavaScript |
values[66] | if values.indices.contains(66) {{ values[66] }} | Check index. | Swift |
switch(a){{ case 67: break; }} | switch(a){{ case 67: break; default: break; }} | Add default case. | Java |
INSERT INTO orders VALUES ('info',78) | INSERT INTO orders (name, status) VALUES ('info',78); | Specify columns. | SQL |
if [ $count = 23 ]; then | if [ "$count" = 23 ]; then | Quote variable. | Shell |
def foo
puts 'message'
end | def foo
puts 'message'
end | Correct. | Ruby |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
class Person {{ int data; }}; | class Person {{ public: int data; }}; | Make public. | C++ |
{{"age":"info" "id":80}} | {{"age":"info", "id":80}} | Add comma. | JSON |
{{'id':'info'}} | {{"id":"info"}} | Use double quotes. | JSON |
let v=vec![61,75,75]; let primary=&v[0]; v.push(62); | let mut v=vec![61,75,75]; let primary=v[0]; v.push(62); | Copy instead of reference. | Rust |
if (a = 46) {} | if (a == 46) {} | Use ==. | Dart |
if (foo = 21) | if (foo == 21) | Use ==. | C++ |
<person name='hello'/> | <person name="hello"/> | Double quotes. | XML |
if (x = 83) {{}} | if (x == 83) {{}} | Use ==. | Kotlin |
'world' + 25 | 'world' + 25.to_s | Convert int. | Ruby |
h1 {{ font-size:40px color:red; }} | h1 {{ font-size:40px; color:red; }} | Add semicolon. | CSS |
if foo = 91: | if foo == 91: | Use == for comparison. | Python |
function baz() {{
return
{{key:'info'}}
}} | function baz() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
$count = 43; if ($count = 43) {{}} | $count = 43; if ($count == 43) {{}} | Use ==. | PHP |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(2); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(2, () => console.log('listening')); | Add callback. | Node.js |
void main() {{ print('message') }} | void main() {{ print('message'); }} | Add semicolon. | Dart |
function process(z:string){{return z;}} process(40); | function process(z:string){{return z;}} process('info'); | Pass correct type. | TypeScript |
$data[25] = 5; | if (isset($data[25])) $data[25] = 5; | Check existence. | PHP |
JOIN products ON items.id = products.age | JOIN products ON items.id = products.age | Correct. | SQL |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
val index: Int = 'result' | val index: String = 'result' | Fix type. | Kotlin |
for i=1,23 do print(i) end | for i=1,23 do print(i) end | Correct. | Lua |
{{'title':20, 'status' 41}} | {{'title':20, 'status':41}} | Colon missing. | Python |
<br></br> | <br> | Self-closing. | HTML |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
switch(y){{ case 48: break; }} | switch(y){{ case 48: break; default: break; }} | Add default case. | Java |
yield a | yield a | Correct yield. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
print('result') | print('result') | Correct. | R |
object Person {{ def main(args: Array[String]) = println("world") }} | object Person {{ def main(args: Array[String]): Unit = println("world") }} | Add return type Unit. | Scala |
def test(z):
return z + 1 | def test(z):
return z + 1 | Correct. | Python |
int items[28]; items[28]=5; | int items[28]; if(28<28){{}} else items[28]=5; | Bounds check. | C++ |
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(69); | const http = require('http'); http.createServer((req,res) => res.end('test')).listen(69); | Correct. | Node.js |
<ul><li>world<li>hello</ul> | <ul><li>world</li><li>hello</li></ul> | Close li. | HTML |
["hello", 96] | ["hello", 96] | Correct. | JSON |
System.out.println('result') | System.out.println('result'); | Add semicolon. | Java |
list[31] | if list.indices.contains(31) {{ list[31] }} | Check index. | Swift |
let c: number | null = null; c.toFixed(98); | let c: number | null = null; if(c!==null) c.toFixed(98); | Null check. | TypeScript |
if (y = 70) {{}} | if (y === 70) {{}} | Use === for equality. | JavaScript |
<input type='text' value='world'> | <input type='text' value='world' name='id'> | Add name attribute. | HTML |
[26, 61, 36 | [26, 61, 36] | Close bracket. | Ruby |
val foo = 91; foo = 54 | var foo = 91; foo = 54 | Use var for reassignment. | Scala |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.