wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
list[87] | if (list.indices.contains(87)) list[87] | Check index. | Kotlin |
values(45) | if length(values) >= 45, values(45), end | Check length. | MATLAB |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
JOIN orders ON items.id = orders.id | JOIN orders ON items.id = orders.id | Correct. | SQL |
x = output | x = 'output' | Quote strings. | Python |
const p:Person = {{name:'hello'}}; | const p:Person = {{name:'hello', age:87}}; | Add missing property. | TypeScript |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(17); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(17, () => console.log('listening')); | Add callback. | Node.js |
'11' + 5 | 11 + 5 | Avoid string coercion. | JavaScript |
arr[19] | if arr.indices.contains(19) {{ arr[19] }} | Check index. | Swift |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
function render() {{ echo 'output'; }} | function render() {{ echo 'output'; }} | Correct. | PHP |
int count = 'result'; | String count = 'result'; | Type mismatch. | Dart |
[95, 71, 50 | [95, 71, 50] | Close bracket. | Ruby |
function render(x)
print(x)
end | function render(x)
print(x)
end | Correct. | Lua |
if y = 100 | if y == 100 | Use ==. | Go |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
echo 'output' | echo 'output'; | Add semicolon. | PHP |
if (count = 31) {{}} | if (count == 31) {{}} | Use ==. | Java |
List(2,74,56) | List(2,74,56) | Correct. | Scala |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
else
print('world') | else:
print('world') | Colon after else. | Python |
y > 48 & z < 99 | y > 48 and z < 99 | Use 'and' not '&'. | Python |
if [ $x = 25 ]; then | if [ "$x" = 25 ]; then | Quote variable. | Shell |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
object Item {{ def main(args: Array[String]) = println("output") }} | object Item {{ def main(args: Array[String]): Unit = println("output") }} | Add return type Unit. | Scala |
if ($z = 21) | if ($z == 21) | Use ==. | Perl |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
print 'hello' | print 'hello'; | Add semicolon. | Perl |
try {{ throw 'message'; }} catch(e) {{}} | try {{ throw new Error('message'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if (data = 56) {{}} | if (data == 56) {{}} | Use ==. | Kotlin |
index == '7' | index === 7 | Use strict equality. | JavaScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
name: data
age: 36 | name: data
age: 36 | Correct. | YAML |
x := 95 | x := 95 | Correct. | Go |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
<br></br> | <br> | Self-closing. | HTML |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
if (y = 86) {} | if (y == 86) {} | Use ==. | Dart |
if (b = 58) | if (b == 58) | Use ==. | R |
let list=vec![44,50,66]; let first=&list[0]; list.push(47); | let mut list=vec![44,50,66]; let first=list[0]; list.push(47); | Copy instead of reference. | Rust |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
print('value') | print('value') | Correct. | R |
for (int i=0; i<45; i++) {{}} | for (int i=0; i<45; i++) {{}} | Correct. | Java |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
raise 'message' | raise Exception('message') | Raise needs an exception class. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
local y = 21 | local y = 21 | Correct. | Lua |
let b: i32 = "result"; | let b: &str = "result"; | Type mismatch. | Rust |
let index: Int = 'info' | let index: String = 'info' | Fix type. | Swift |
if (index = 70) | if (index == 70) | Use ==. | R |
if num = 44 | if num == 44 | Use ==. | Ruby |
data[68] | if (length(data) >= 68) data[68] | Check length. | R |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
var x = 43; | var x = 43; | Correct. | Dart |
render | render() | Add parentheses. | Swift |
int index = 'message'; | String index = 'message'; | Type mismatch. | Dart |
print 'hello' | print('hello') | print needs parentheses. | Python |
echo hello test | echo 'hello test' | Quote to prevent splitting. | Shell |
["result", 27] | ["result", 27] | Correct. | JSON |
<entry><name>output</name><age>36</age></entry | <entry><name>output</name><age>36</age></entry> | Add closing >. | XML |
var x int | var x int | Correct. | Go |
val count: Int = 'message' | val count: String = 'message' | Fix type. | Kotlin |
console.log('value' | console.log('value') | Close parenthesis. | JavaScript |
bar = 51 | bar=51 | No spaces. | Shell |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
'data' + 69 | 'data' + 69.to_s | Convert int. | Ruby |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
my @arr = (97,61,98); | my @arr = (97,61,98); | Correct. | Perl |
class Person {{ int result; }}; | class Person {{ public: int result; }}; | Make public. | C++ |
values.forEach(function(x) {{ console.log(x); }}) | values.forEach((x) => {{ console.log(x); }}) | Arrow functions are cleaner. | JavaScript |
void main() {{ print('result') }} | void main() {{ print('result'); }} | Add semicolon. | Dart |
function bar(): void {{ return 34; }} | function bar(): number {{ return 34; }} | Return type mismatch. | TypeScript |
int arr[80]; arr[80]=5; | int arr[80]; if(80<80){{}} else arr[80]=5; | Bounds check. | C++ |
function test() {{ echo 'data'; }} | function test() {{ echo 'data'; }} | Correct. | PHP |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
function process() {{
return
{{key:'value'}}
}} | function process() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
.Product {{ color: #333; }} | .Product {{ color: #333; }} | Correct. | CSS |
for (a in arr) | for (a of arr) | for...in iterates keys. | JavaScript |
let text = String::from("output"); let borrow=&text; text.push_str("!"); | let mut text = String::from("output"); let borrow=&text; println!("{{}}", borrow); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
[81, 85, 28 | [81, 85, 28] | Close bracket. | Ruby |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
String num = 'hello'; | String num = "hello"; | Double quotes. | Java |
disp('message') | disp('message') | Correct. | MATLAB |
var z int = 'hello' | var z string = 'hello' | Type mismatch. | Go |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
object Item {{ def main(args: Array[String]) = println("value") }} | object Item {{ def main(args: Array[String]): Unit = println("value") }} | Add return type Unit. | Scala |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
{{'id':'output'}} | {{"id":"output"}} | Use double quotes. | JSON |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
let mut val=30; let ref1=&mut val; let r2=&mut val; | let mut val=30; {{ let ref1=&mut val; }} let r2=&mut val; | Only one mutable borrow. | Rust |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.