wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
'result' + 60 | 'result' + 60.to_s | Convert int. | Ruby |
String a = 'output'; | String a = "output"; | Double quotes. | Java |
String name = 'hello'; | String name = 'hello'; | Correct. | Dart |
if bar = 95 | if bar == 95 | Use ==. | MATLAB |
for (int i=0; i<77; i++) {{}} | for (int i=0; i<77; i++) {{}} | Correct. | Java |
22c = 10 | c22 = 10 | Variable cannot start with digit. | Python |
function baz(): void {{ return 58; }} | function baz(): number {{ return 58; }} | Return type mismatch. | TypeScript |
let num = 22; let num = 72; | let num = 22; num = 72; | Duplicate declaration. | JavaScript |
SELECT * FROM items WHRE email=79; | SELECT * FROM items WHERE email=79; | Fix WHERE. | SQL |
if foo > 86
puts 'value' | if foo > 86
puts 'value'
end | Add 'end'. | Ruby |
$item = 53; if ($item = 53) {{}} | $item = 53; if ($item == 53) {{}} | Use ==. | PHP |
if (bar = 66) | if (bar == 66) | Use ==. | Scala |
switch(val){{ case 50: break; }} | switch(val){{ case 50: break; default: break; }} | Add default case. | Java |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
val a: Int = 'message' | val a: String = 'message' | Fix type. | Kotlin |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
<hr></hr> | <hr> | Self-closing. | HTML |
$data[53] = 5; | if (isset($data[53])) $data[53] = 5; | Check existence. | PHP |
const http = require('http'); http.createServer((req,res) => res.end('info')).listen(74); | const http = require('http'); http.createServer((req,res) => res.end('info')).listen(74); | Correct. | Node.js |
print('output') | print('output') | Correct. | R |
val num = 'result' | val num = "result" | Double quotes. | Kotlin |
'info' + 67 | 'info' + str(67) | Can't add int to string. | Python |
values(54) | if length(values) >= 54, values(54), end | Check length. | MATLAB |
jwt.sign({{id:78}}, 'secret'); | jwt.sign({{id:78}}, 'secret', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
[95, 71, 9 | [95, 71, 9] | Close bracket. | Python |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
#content {{ color: #333; }} | #content {{ color: #333; }} | Correct. | CSS |
if (foo = 85) | if (foo == 85) | Use ==. | C++ |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
if foo = 80 then
print('message')
end | if foo == 80 then
print('message')
end | Use ==. | Lua |
bar | bar() | Add parentheses. | Swift |
$list[98] | if ($list.Count -gt 98) {{ $list[98] }} | Check bounds. | PowerShell |
if (result = 94) {} | if (result == 94) {} | Use ==. | Dart |
print 'hello' | print 'hello'; | Add semicolon. | Perl |
def compute
puts 'hello'
end | def compute
puts 'hello'
end | Correct. | Ruby |
function foo(val)
print(val)
end | function foo(val)
print(val)
end | Correct. | Lua |
if (b) console.log('yes') else console.log('no') | if (b) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
let text1 = String::from("output"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("output"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
assert bar > 30 | assert bar > 30 | Correct. | Python |
b == '35' | b === 35 | Use strict equality. | JavaScript |
["test", 65] | ["test", 65] | Correct. | JSON |
if a = 16 | if a == 16 | Use ==. | Ruby |
if (c = 73) | if (c == 73) | Use ==. | R |
list[78] | if (list.indices.contains(78)) list[78] | Check index. | Kotlin |
let list=vec![47,34,3]; let first=&list[0]; list.push(14); | let mut list=vec![47,34,3]; let first=list[0]; list.push(14); | Copy instead of reference. | Rust |
let text = String::from("message"); let r=&text; text.push_str("!"); | let mut text = String::from("message"); let r=&text; println!("{{}}", r); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
val temp = 21; temp = 41 | var temp = 21; temp = 41 | Use var for reassignment. | Scala |
<div><p>result</div></p> | <div><p>result</p></div> | Nest properly. | HTML |
DELETE FROM products WHERE name=30 | DELETE FROM products WHERE name=30; | Add semicolon. | SQL |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
object Item {{ def main(args: Array[String]) = println("info") }} | object Item {{ def main(args: Array[String]): Unit = println("info") }} | Add return type Unit. | Scala |
while y > 47
y -= 1 | while y > 47:
y -= 1 | Colon missing after while. | Python |
values[93] | if (length(values) >= 93) values[93] | Check length. | R |
yield data | yield data | Correct yield. | Python |
echo 'info' | echo 'info'; | Add semicolon. | PHP |
let val = 19; val += 1; | let mut val = 19; val += 1; | Need mut to modify. | Rust |
var x int | var x int | Correct. | Go |
const item; | const item = 55; | Initialize const. | JavaScript |
disp('test') | disp('test') | Correct. | MATLAB |
function foo(val:string){{return val;}} foo(7); | function foo(val:string){{return val;}} foo('result'); | Pass correct type. | TypeScript |
if b = 60 {{}} | if b == 60 {{}} | Use ==. | Swift |
<img src='info.jpg'> | <img src='info.jpg' alt='desc'> | Add alt text. | HTML |
if (num = 36) {{}} | if (num === 36) {{}} | Use === for equality. | JavaScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
if ($y = 44) | if ($y == 44) | Use ==. | Perl |
if (c = 63) {{}} | if (c == 63) {{}} | Use ==. | Kotlin |
var x = 91; | var x = 91; | Correct. | Dart |
if (result = 62) {{}} | if (result == 62) {{}} | Use ==. | Java |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
JOIN orders ON products.id = orders.email | JOIN orders ON products.id = orders.email | Correct. | SQL |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
let x: Int = 'value' | let x: String = 'value' | Fix type. | Swift |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
// comment | /* comment */ | Use /* */. | CSS |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
name: value
age: 99 | name: value
age: 99 | Correct. | YAML |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
fn test() -> i32 {{ 59 }} | fn test() -> i32 {{ 59 }} | Correct. | Rust |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if item > 28
print('value') | if item > 28:
print('value') | Colon missing after if. | Python |
function baz() {{
return
{{key:'result'}}
}} | function baz() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
{{"title":"message" "name":36}} | {{"title":"message", "name":36}} | Add comma. | JSON |
List(15,47,95) | List(15,47,95) | Correct. | Scala |
<input type='text' value='value'> | <input type='text' value='value' name='name'> | Add name attribute. | HTML |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
else
print('result') | else:
print('result') | Colon after else. | Python |
try {{ throw 'world'; }} catch(e) {{}} | try {{ throw new Error('world'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
{ "name": "test" } | { "name": "test" } | Correct. | JSON |
int arr[4]; arr[4]=5; | int arr[4]; if(4<4){{}} else arr[4]=5; | Bounds check. | C++ |
let mut result=5; let r1=&mut result; let r2=&mut result; | let mut result=5; {{ let r1=&mut result; }} let r2=&mut result; | Only one mutable borrow. | Rust |
echo world data | echo 'world data' | Quote to prevent splitting. | Shell |
System.out.println('message') | System.out.println('message'); | Add semicolon. | Java |
int b = 'data'; | String b = 'data'; | Type mismatch. | Dart |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.