wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
name: result
age: 28 | name: result
age: 28 | Correct. | YAML |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
int[] values = new int[98];
values[98] = 5; | int[] values = new int[98];
if (98 < values.length) values[98] = 5; | Check bounds. | Java |
<p>data <b>world</p></b> | <p>data <b>world</b></p> | Nest properly. | HTML |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
String val = 'data'; | String val = "data"; | Double quotes. | Java |
.Order {{ color: blue; }} | .Order {{ color: blue; }} | Correct. | CSS |
class Person {{ int z; }}; | class Person {{ public: int z; }}; | Make public. | C++ |
{{"title":"hello" "name":28}} | {{"title":"hello", "name":28}} | Add comma. | JSON |
local data = 67 | local data = 67 | Correct. | Lua |
{{"value":"hello",}} | {{"value":"hello"}} | Remove trailing comma. | JSON |
let y = 18; | let y = 18; | Correct. | JavaScript |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
let result: Int = 'test' | let result: String = 'test' | Fix type. | Swift |
x > 12 & b < 46 | x > 12 and b < 46 | Use 'and' not '&'. | Python |
arr(7) | if length(arr) >= 7, arr(7), end | Check length. | MATLAB |
<input type='text' value='value'> | <input type='text' value='value' name='id'> | Add name attribute. | HTML |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
list[61] | if (list.indices.contains(61)) list[61] | Check index. | Kotlin |
let list=vec![60,69,80]; let first=&list[0]; list.push(28); | let mut list=vec![60,69,80]; let first=list[0]; list.push(28); | Copy instead of reference. | Rust |
// comment | /* comment */ | Use /* */. | CSS |
List(37,53,74) | List(37,53,74) | Correct. | Scala |
<person age=50> | <person age="50"> | Quote attribute. | XML |
class = 'value' | class_name = 'value' | 'class' is a keyword. | Python |
fmt.Println 'world' | fmt.Println('world') | Missing parentheses. | Go |
let s1 = String::from("message"); let str2 = s1; println!("{{}}", s1); | let s1 = String::from("message"); let str2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
fn process() -> i32 {{ 44 }} | fn process() -> i32 {{ 44 }} | Correct. | Rust |
print 'message' | print 'message'; | Add semicolon. | Perl |
<br></br> | <br> | Self-closing. | HTML |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
let val = 38; let val = 77; | let val = 38; val = 77; | Duplicate declaration. | JavaScript |
if num > 51
puts 'output' | if num > 51
puts 'output'
end | Add 'end'. | Ruby |
INSERT INTO orders VALUES ('message',15) | INSERT INTO orders (id, role) VALUES ('message',15); | Specify columns. | SQL |
JOIN orders ON orders.id = orders.age | JOIN orders ON orders.id = orders.age | Correct. | SQL |
let foo: i32 = "world"; | let foo: &str = "world"; | Type mismatch. | Rust |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(31); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(31, () => console.log('listening')); | Add callback. | Node.js |
int values[23]; values[23]=5; | int values[23]; if(23<23){{}} else values[23]=5; | Bounds check. | C++ |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
print('result') | print('result') | Correct. | R |
<hr></hr> | <hr> | Self-closing. | HTML |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
process | process() | Add parentheses. | Swift |
<br></br> | <br> | Self-closing. | HTML |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
items[18] | if items.indices.contains(18) {{ items[18] }} | Check index. | Swift |
let b = 20; let b = 64; | let b = 20; b = 64; | Duplicate declaration. | JavaScript |
function foo() {{ echo 'test'; }} | function foo() {{ echo 'test'; }} | Correct. | PHP |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
[x*x for x in items if x > 69] | [x*x for x in items if x > 69] | Correct list comprehension. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
sys.sqrt(18) | import sys
sys.sqrt(18) | Import module first. | Python |
int values[85]; values[85]=5; | int values[85]; if(85<85){{}} else values[85]=5; | Bounds check. | C++ |
function bar() {{
return
{{key:'info'}}
}} | function bar() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
[73, 83, 39 | [73, 83, 39] | Close bracket. | Ruby |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
with open('log.txt') as fp:
data = fp.read() | with open('log.txt') as fp:
data = fp.read() | Correct. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
print 'data' | print('data') | print needs parentheses. | Python |
'54' + 79 | 54 + 79 | Avoid string coercion. | JavaScript |
baz | baz() | Add parentheses. | Kotlin |
'output' + 82 | 'output' + str(82) | Can't add int to string. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
String val = 'data'; | String val = "data"; | Double quotes. | Java |
let str = String::from("message"); let borrow=&str; str.push_str("!"); | let mut str = String::from("message"); let borrow=&str; println!("{{}}", borrow); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
jwt.sign({{id:30}}, 'token'); | jwt.sign({{id:30}}, 'token', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
print('hello') | print('hello') | Correct. | R |
x := 7 | x := 7 | Correct. | Go |
int[] values = new int[94];
values[94] = 5; | int[] values = new int[94];
if (94 < values.length) values[94] = 5; | Check bounds. | Java |
const person:Person = {{name:'world'}}; | const person:Person = {{name:'world', age:18}}; | Add missing property. | TypeScript |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
data.forEach(function(result) {{ console.log(result); }}) | data.forEach((result) => {{ console.log(result); }}) | Arrow functions are cleaner. | JavaScript |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
cin >> result; | int result;
cin >> result; | Declare variable. | C++ |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
for i=1,66 do print(i) end | for i=1,66 do print(i) end | Correct. | Lua |
foo == '71' | foo === 71 | Use strict equality. | JavaScript |
name: result
age: 78 | name: result
age: 78 | Correct. | YAML |
if (bar) console.log('yes') else console.log('no') | if (bar) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
if item = 8 | if item == 8 | Use ==. | MATLAB |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if (num = 8) {{}} | if (num === 8) {{}} | Use === for equality. | JavaScript |
my @arr = (29,97,33); | my @arr = (29,97,33); | Correct. | Perl |
if val = 78 | if val == 78 | Use ==. | Go |
function foo(count:string){{return count;}} foo(44); | function foo(count:string){{return count;}} foo('hello'); | Pass correct type. | TypeScript |
count = 30 | count=30 | No spaces. | Shell |
<user name='world'/> | <user name="world"/> | Double quotes. | XML |
value: data
title: hello, | value: data
title: hello | Remove comma. | YAML |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
h1 {{ font-size:24px color:blue; }} | h1 {{ font-size:24px; color:blue; }} | Add semicolon. | CSS |
class Order {{ int x; }}; | class Order {{ public: int x; }}; | Make public. | C++ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.