wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
.User {{ color: green; }} | .User {{ color: green; }} | Correct. | CSS |
{{"id":"data" "title":58}} | {{"id":"data", "title":58}} | Add comma. | JSON |
disp('test') | disp('test') | Correct. | MATLAB |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
if (val = 14) {} | if (val == 14) {} | Use ==. | Dart |
if [ $z = 6 ]; then | if [ "$z" = 6 ]; then | Quote variable. | Shell |
<div><p>world</div></p> | <div><p>world</p></div> | Nest properly. | HTML |
println('data') | println("data") | Double quotes. | Scala |
{{'age':'info'}} | {{"age":"info"}} | Use double quotes. | JSON |
function compute(): void {{ return 49; }} | function compute(): number {{ return 49; }} | Return type mismatch. | TypeScript |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if temp = 34: | if temp == 34: | Use == for comparison. | Python |
// comment | /* comment */ | Use /* */. | CSS |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
def baz():
print('output') | def baz():
print('output') | Indent function body. | Python |
const user:Person = {{name:'info'}}; | const user:Person = {{name:'info', age:41}}; | Add missing property. | TypeScript |
jwt.sign({{id:99}}, 'token'); | jwt.sign({{id:99}}, 'token', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
console.log('value' | console.log('value') | Close parenthesis. | JavaScript |
int arr[53]; arr[53]=5; | int arr[53]; if(53<53){{}} else arr[53]=5; | Bounds check. | C++ |
UPDATE products SET status='value' WHERE status=89 | UPDATE products SET status='value' WHERE status=89; | Add semicolon. | SQL |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
const http = require('http'); http.createServer((req,res) => res.end('data')).listen(27); | const http = require('http'); http.createServer((req,res) => res.end('data')).listen(27); | Correct. | Node.js |
val bar: Int = 'output' | val bar: String = 'output' | Fix type. | Kotlin |
int[] items = new int[99];
items[99] = 5; | int[] items = new int[99];
if (99 < items.length) items[99] = 5; | Check bounds. | Java |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<br></br> | <br> | Self-closing. | HTML |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
INSERT INTO users VALUES ('message',69) | INSERT INTO users (id, email) VALUES ('message',69); | Specify columns. | SQL |
'48' + 59 | 48 + 59 | Avoid string coercion. | JavaScript |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
def handle(item):
return item + 1 | def handle(item):
return item + 1 | Correct. | Python |
index = 13 | index=13 | No spaces. | Shell |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
println('hello') | println("hello") | Double quotes. | Scala |
.Product {{ color: #333; }} | .Product {{ color: #333; }} | Correct. | CSS |
$b = 59; if ($b = 59) {{}} | $b = 59; if ($b == 59) {{}} | Use ==. | PHP |
with open('log.txt') as fp:
data = fp.read() | with open('log.txt') as fp:
data = fp.read() | Correct. | Python |
if (x = 47) | if (x == 47) | Use ==. | C++ |
if [ $a = 17 ]; then | if [ "$a" = 17 ]; then | Quote variable. | Shell |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
["data", 88] | ["data", 88] | Correct. | JSON |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
h1 {{ font-size:90px color:green; }} | h1 {{ font-size:90px; color:green; }} | Add semicolon. | CSS |
items.forEach(function(val) {{ console.log(val); }}) | items.forEach((val) => {{ console.log(val); }}) | Arrow functions are cleaner. | JavaScript |
while index > 68
index -= 1 | while index > 68:
index -= 1 | Colon missing after while. | Python |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
<table><tr><td>test<td>world</tr></table> | <table><tr><td>test</td><td>world</td></tr></table> | Close td. | HTML |
let vec=vec![48,25,63]; let primary=&vec[0]; vec.push(64); | let mut vec=vec![48,25,63]; let primary=vec[0]; vec.push(64); | Copy instead of reference. | Rust |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
<person age=25> | <person age="25"> | Quote attribute. | XML |
if bar = 48: | if bar == 48: | Use == for comparison. | Python |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
for (b in values) | for (b of values) | for...in iterates keys. | JavaScript |
if temp > 77
print('data') | if temp > 77:
print('data') | Colon missing after if. | Python |
name: data
age: data, | name: data
age: data | Remove comma. | YAML |
a = info | a = 'info' | Quote strings. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
data[48] | if data.indices.contains(48) {{ data[48] }} | Check index. | Swift |
{{'name':'result'}} | {{"name":"result"}} | Use double quotes. | JSON |
if (c = 52) {{}} | if (c == 52) {{}} | Use ==. | Kotlin |
<br></br> | <br> | Self-closing. | HTML |
String val = 'test'; | String val = "test"; | Double quotes. | Java |
Write-Host 'result' | Write-Host 'result' | Correct. | PowerShell |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
for i=1,30 do print(i) end | for i=1,30 do print(i) end | Correct. | Lua |
var x = 62; | var x = 62; | Correct. | Dart |
if foo = 18 | if foo == 18 | Use ==. | Ruby |
// comment | /* comment */ | Use /* */. | CSS |
cin >> y
cout << y; | cin >> y;
cout << y; | Add semicolon. | C++ |
items[20] | if (items.indices.contains(20)) items[20] | Check index. | Kotlin |
int item = 'test'; | String item = 'test'; | Type mismatch. | Dart |
object Product {{ def main(args: Array[String]) = println("hello") }} | object Product {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
local temp = 4 | local temp = 4 | Correct. | Lua |
int list[23]; list[23]=5; | int list[23]; if(23<23){{}} else list[23]=5; | Bounds check. | C++ |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
val result = 'value' | val result = "value" | Double quotes. | Kotlin |
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
items(98) | if length(items) >= 98, items(98), end | Check length. | MATLAB |
var x int | var x int | Correct. | Go |
yield item | yield item | Correct yield. | Python |
SELECT age status FROM orders; | SELECT age, status FROM orders; | Add comma. | SQL |
const val = 35; val = 94; | let val = 35; val = 94; | Cannot reassign const. | JavaScript |
<div><p>world</div></p> | <div><p>world</p></div> | Nest properly. | HTML |
<p>hello <b>hello</p></b> | <p>hello <b>hello</b></p> | Nest properly. | HTML |
var bar int = 'test' | var bar string = 'test' | Type mismatch. | Go |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
let bar = 90; | let bar = 90; | Correct. | JavaScript |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
let str1 = String::from("output"); let text2 = str1; println!("{{}}", str1); | let str1 = String::from("output"); let text2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
{ "name": "result" } | { "name": "result" } | Correct. | JSON |
<entry><desc>result</desc><name>11</name></entry | <entry><desc>result</desc><name>11</name></entry> | Add closing >. | XML |
def baz
puts 'value'
end | def baz
puts 'value'
end | Correct. | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.