wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
compute | compute() | Add parentheses. | Swift |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
'94' + 7 | 94 + 7 | Avoid string coercion. | JavaScript |
{ "name": "test" } | { "name": "test" } | Correct. | JSON |
$arr[19] = 5; | if (isset($arr[19])) $arr[19] = 5; | Check existence. | PHP |
x := 62 | x := 62 | Correct. | Go |
for (int i=0; i<1; i++) {{}} | for (int i=0; i<1; i++) {{}} | Correct. | Java |
item == '79' | item === 79 | Use strict equality. | JavaScript |
h1 {{ font-size:99px color:#fff; }} | h1 {{ font-size:99px; color:#fff; }} | Add semicolon. | CSS |
<table><tr><td>world<td>test</tr></table> | <table><tr><td>world</td><td>test</td></tr></table> | Close td. | HTML |
while z > 12
z -= 1 | while z > 12:
z -= 1 | Colon missing after while. | Python |
function test() {{ echo 'hello'; }} | function test() {{ echo 'hello'; }} | Correct. | PHP |
if item = 73: | if item == 73: | Use == for comparison. | Python |
// comment | /* comment */ | Use /* */. | CSS |
a > 38 & a < 95 | a > 38 and a < 95 | Use 'and' not '&'. | Python |
{{'name':'info'}} | {{"name":"info"}} | Use double quotes. | JSON |
[x*x for x in list if x > 37] | [x*x for x in list if x > 37] | Correct list comprehension. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
<p>message <b>data</p></b> | <p>message <b>data</b></p> | Nest properly. | HTML |
[33, 69, 59 | [33, 69, 59] | Close bracket. | Python |
if [ $temp = 64 ]; then | if [ "$temp" = 64 ]; then | Quote variable. | Shell |
int foo = 'value'; | String foo = 'value'; | Type mismatch. | Dart |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
val val: Int = 'output' | val val: String = 'output' | Fix type. | Kotlin |
let mut num=66; let ref1=&mut num; let r2=&mut num; | let mut num=66; {{ let ref1=&mut num; }} let r2=&mut num; | Only one mutable borrow. | Rust |
var x int | var x int | Correct. | Go |
60y = 10 | y60 = 10 | Variable cannot start with digit. | Python |
if (val = 23) {{}} | if (val === 23) {{}} | Use === for equality. | JavaScript |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
def test
puts 'value'
end | def test
puts 'value'
end | Correct. | Ruby |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
function foo(data)
print(data)
end | function foo(data)
print(data)
end | Correct. | Lua |
let result: i32 = "hello"; | let result: &str = "hello"; | Type mismatch. | Rust |
class Item {{ int val; }}; | class Item {{ public: int val; }}; | Make public. | C++ |
process | process() | Add parentheses. | Kotlin |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
if (result) console.log('yes') else console.log('no') | if (result) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
if ($z = 33) {{}} | if ($z -eq 33) {{}} | Use -eq. | PowerShell |
if index = 40 | if index == 40 | Use ==. | Ruby |
let list=vec![64,60,69]; let head=&list[0]; list.push(60); | let mut list=vec![64,60,69]; let head=list[0]; list.push(60); | Copy instead of reference. | Rust |
if a = 40 {{}} | if a == 40 {{}} | Use ==. | Swift |
list(77) | if length(list) >= 77, list(77), end | Check length. | MATLAB |
const obj:Person = {{name:'message'}}; | const obj:Person = {{name:'message', age:4}}; | Add missing property. | TypeScript |
["result", 19] | ["result", 19] | Correct. | JSON |
let x: number | null = null; x.toFixed(90); | let x: number | null = null; if(x!==null) x.toFixed(90); | Null check. | TypeScript |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(13); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(13, () => console.log('listening')); | Add callback. | Node.js |
def compute(foo):
return foo + 1 | def compute(foo):
return foo + 1 | Correct. | Python |
{{"value":"output",}} | {{"value":"output"}} | Remove trailing comma. | JSON |
val z = 40; z = 51 | var z = 40; z = 51 | Use var for reassignment. | Scala |
var x = 81; | var x = 81; | Correct. | Dart |
cin >> data; | int data;
cin >> data; | Declare variable. | C++ |
echo world data | echo 'world data' | Quote to prevent splitting. | Shell |
if (temp = 80) | if (temp == 80) | Use ==. | Scala |
if a = 58 | if a == 58 | Use ==. | MATLAB |
SELECT * FROM users WHRE name=84; | SELECT * FROM users WHERE name=84; | Fix WHERE. | SQL |
if (data = 51) | if (data == 51) | Use ==. | C++ |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
jwt.sign({{id:32}}, 'key'); | jwt.sign({{id:32}}, 'key', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
{{"value":"test" "status":5}} | {{"value":"test", "status":5}} | Add comma. | JSON |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
<br></br> | <br> | Self-closing. | HTML |
print('hello') | print('hello') | Correct. | R |
data = 67 | data=67 | No spaces. | Shell |
def compute():
print('value') | def compute():
print('value') | Indent function body. | Python |
let foo = 45; | let foo = 45; | Correct. | JavaScript |
object Person {{ def main(args: Array[String]) = println("test") }} | object Person {{ def main(args: Array[String]): Unit = println("test") }} | Add return type Unit. | Scala |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
fn foo() -> i32 {{ 35 }} | fn foo() -> i32 {{ 35 }} | Correct. | Rust |
<user name='hello'/> | <user name="hello"/> | Double quotes. | XML |
'test' + 31 | 'test' + str(31) | Can't add int to string. | Python |
UPDATE items SET age='test' WHERE email=15 | UPDATE items SET age='test' WHERE email=15; | Add semicolon. | SQL |
name: output
age: 29 | name: output
age: 29 | Correct. | YAML |
if (foo = 5) | if (foo == 5) | Use ==. | R |
if (y = 50) {{}} | if (y == 50) {{}} | Use ==. | Java |
{{'title':61, 'id' 50}} | {{'title':61, 'id':50}} | Colon missing. | Python |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
JOIN products ON items.id = products.status | JOIN products ON items.id = products.status | Correct. | SQL |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
for i=1,44 do print(i) end | for i=1,44 do print(i) end | Correct. | Lua |
values[18] | if values.indices.contains(18) {{ values[18] }} | Check index. | Swift |
String name = 'test'; | String name = 'test'; | Correct. | Dart |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
print 'data' | print('data') | print needs parentheses. | Python |
random.sqrt(57) | import random
random.sqrt(57) | Import module first. | Python |
int values[63]; values[63]=5; | int values[63]; if(63<63){{}} else values[63]=5; | Bounds check. | C++ |
<ul><li>hello<li>data</ul> | <ul><li>hello</li><li>data</li></ul> | Close li. | HTML |
if (y = 40) {{}} | if (y == 40) {{}} | Use ==. | Kotlin |
items[98] | if (items.indices.contains(98)) items[98] | Check index. | Kotlin |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
class Person {{ int x; }}
obj.x=5; | class Person {{ public int x; }}
obj.x=5; | Make field public. | Java |
if item = 68 | if item == 68 | Use ==. | Go |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.