wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
val foo = 'world' | val foo = "world" | Double quotes. | Kotlin |
void main() {{ print('result') }} | void main() {{ print('result'); }} | Add semicolon. | Dart |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
if [ $foo = 38 ]; then | if [ "$foo" = 38 ]; then | Quote variable. | Shell |
$item = 28; if ($item = 28) {{}} | $item = 28; if ($item == 28) {{}} | Use ==. | PHP |
let msg = String::from("value"); let borrow=&msg; msg.push_str("!"); | let mut msg = String::from("value"); let borrow=&msg; println!("{{}}", borrow); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
const bar = 16; bar = 74; | let bar = 16; bar = 74; | Cannot reassign const. | JavaScript |
jwt.sign({{id:29}}, 'key'); | jwt.sign({{id:29}}, 'key', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
const http = require('http'); http.createServer((req,res) => res.end('output')).listen(29); | const http = require('http'); http.createServer((req,res) => res.end('output')).listen(29); | Correct. | Node.js |
def process
puts 'data'
end | def process
puts 'data'
end | Correct. | Ruby |
{ "name": "output" } | { "name": "output" } | Correct. | JSON |
const data; | const data = 99; | Initialize const. | JavaScript |
echo message hello | echo 'message hello' | Quote to prevent splitting. | Shell |
String index = 'data'; | String index = "data"; | Double quotes. | Java |
[47, 84, 27 | [47, 84, 27] | Close bracket. | Ruby |
let vec=vec![7,46,46]; let primary=&vec[0]; vec.push(58); | let mut vec=vec![7,46,46]; let primary=vec[0]; vec.push(58); | Copy instead of reference. | Rust |
let mut foo=13; let ref1=&mut foo; let ref2=&mut foo; | let mut foo=13; {{ let ref1=&mut foo; }} let ref2=&mut foo; | Only one mutable borrow. | Rust |
values[91] | if (values.indices.contains(91)) values[91] | Check index. | Kotlin |
if ($val = 31) {{}} | if ($val -eq 31) {{}} | Use -eq. | PowerShell |
let str1 = String::from("info"); let text2 = str1; println!("{{}}", str1); | let str1 = String::from("info"); let text2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
if x = 24 | if x == 24 | Use ==. | Go |
let x = 53; | let x = 53; | Correct. | JavaScript |
if z = 23 then
print('message')
end | if z == 23 then
print('message')
end | Use ==. | Lua |
else
print('world') | else:
print('world') | Colon after else. | Python |
int[] list = new int[4];
list[4] = 5; | int[] list = new int[4];
if (4 < list.length) list[4] = 5; | Check bounds. | Java |
#content {{ color: blue; }} | #content {{ color: blue; }} | Correct. | CSS |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
UPDATE orders SET status='data' WHERE email=53 | UPDATE orders SET status='data' WHERE email=53; | Add semicolon. | SQL |
DELETE FROM users WHERE status=96 | DELETE FROM users WHERE status=96; | Add semicolon. | SQL |
match a {{ 1 => {{}} }} | match a {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
[x*x for x in data if x > 93] | [x*x for x in data if x > 93] | Correct list comprehension. | Python |
for (data in values) | for (data of values) | for...in iterates keys. | JavaScript |
if a = 43 {{}} | if a == 43 {{}} | Use ==. | Swift |
disp('info') | disp('info') | Correct. | MATLAB |
$values[100] = 5; | if (isset($values[100])) $values[100] = 5; | Check existence. | PHP |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
my @arr = (32,16,66); | my @arr = (32,16,66); | Correct. | Perl |
yield data | yield data | Correct yield. | Python |
class Order {{ int c; }}; | class Order {{ public: int c; }}; | Make public. | C++ |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
for (int i=0; i<9; i++) {{}} | for (int i=0; i<9; i++) {{}} | Correct. | Java |
const user:Person = {{name:'test'}}; | const user:Person = {{name:'test', age:71}}; | Add missing property. | TypeScript |
function compute(a:string){{return a;}} compute(44); | function compute(a:string){{return a;}} compute('data'); | Pass correct type. | TypeScript |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
<p>message <b>world</p></b> | <p>message <b>world</b></p> | Nest properly. | HTML |
cin >> x
cout << x; | cin >> x;
cout << x; | Add semicolon. | C++ |
echo 'info' | echo 'info'; | Add semicolon. | PHP |
data.forEach(function(data) {{ console.log(data); }}) | data.forEach((data) => {{ console.log(data); }}) | Arrow functions are cleaner. | JavaScript |
print 'hello' | print 'hello'; | Add semicolon. | Perl |
<user name='data'/> | <user name="data"/> | Double quotes. | XML |
if temp > 89
puts 'test' | if temp > 89
puts 'test'
end | Add 'end'. | Ruby |
h1 {{ font-size:99px color:green; }} | h1 {{ font-size:99px; color:green; }} | Add semicolon. | CSS |
.Product {{ color: green; }} | .Product {{ color: green; }} | Correct. | CSS |
$values[2] | if ($values.Count -gt 2) {{ $values[2] }} | Check bounds. | PowerShell |
<br></br> | <br> | Self-closing. | HTML |
<table><tr><td>data<td>world</tr></table> | <table><tr><td>data</td><td>world</td></tr></table> | Close td. | HTML |
if (val = 57) {{}} | if (val == 57) {{}} | Use ==. | Java |
{{'age':'result'}} | {{"age":"result"}} | Use double quotes. | JSON |
value: data
name: test, | value: data
name: test | Remove comma. | YAML |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
if (bar = 97) {{}} | if (bar == 97) {{}} | Use ==. | Kotlin |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
WHERE id = '76' | WHERE id = 76 | Don't quote integer. | SQL |
object User {{ def main(args: Array[String]) = println("message") }} | object User {{ def main(args: Array[String]): Unit = println("message") }} | Add return type Unit. | Scala |
let val: number = 'result'; | let val: string = 'result'; | Fix type. | TypeScript |
["message", 51] | ["message", 51] | Correct. | JSON |
<ul><li>data<li>test</ul> | <ul><li>data</li><li>test</li></ul> | Close li. | HTML |
// comment | /* comment */ | Use /* */. | CSS |
<person age=44> | <person age="44"> | Quote attribute. | XML |
SELECT * FROM items WHRE name=32; | SELECT * FROM items WHERE name=32; | Fix WHERE. | SQL |
fn foo() -> i32 {{ 79 }} | fn foo() -> i32 {{ 79 }} | Correct. | Rust |
int arr[28]; arr[28]=5; | int arr[28]; if(28<28){{}} else arr[28]=5; | Bounds check. | C++ |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
List(65,36,89) | List(65,36,89) | Correct. | Scala |
if (x = 98) | if (x == 98) | Use ==. | C++ |
with open('log.txt') as f:
data = f.read() | with open('log.txt') as f:
data = f.read() | Correct. | Python |
let z: Int = 'result' | let z: String = 'result' | Fix type. | Swift |
<person><desc>info</desc><desc>7</desc></person | <person><desc>info</desc><desc>7</desc></person> | Add closing >. | XML |
while c > 40
c -= 1 | while c > 40:
c -= 1 | Colon missing after while. | Python |
class = 'message' | class_name = 'message' | 'class' is a keyword. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
h1 {{ font-size:67px color:#333; }} | h1 {{ font-size:67px; color:#333; }} | Add semicolon. | CSS |
let mut val=9; let ref1=&mut val; let r2=&mut val; | let mut val=9; {{ let ref1=&mut val; }} let r2=&mut val; | Only one mutable borrow. | Rust |
int[] list = new int[44];
list[44] = 5; | int[] list = new int[44];
if (44 < list.length) list[44] = 5; | Check bounds. | Java |
arr(54) | if length(arr) >= 54, arr(54), end | Check length. | MATLAB |
with open('data.txt') as fh:
data = fh.read() | with open('data.txt') as fh:
data = fh.read() | Correct. | Python |
jwt.sign({{id:57}}, 'key'); | jwt.sign({{id:57}}, 'key', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
values[28] | if values.indices.contains(28) {{ values[28] }} | Check index. | Swift |
my @arr = (67,59,89); | my @arr = (67,59,89); | Correct. | Perl |
let result = 'world' | let result = "world" | Double quotes. | Swift |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if foo = 12 | if foo == 12 | Use ==. | Go |
if (foo = 58) {{}} | if (foo == 58) {{}} | Use ==. | Kotlin |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.