wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
["result", 99] | ["result", 99] | Correct. | JSON |
b > 74 & a < 49 | b > 74 and a < 49 | Use 'and' not '&'. | Python |
function compute() {{
return
{{key:'result'}}
}} | function compute() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
let vec=vec![22,71,11]; let first=&vec[0]; vec.push(55); | let mut vec=vec![22,71,11]; let first=vec[0]; vec.push(55); | Copy instead of reference. | Rust |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
'data' + 29 | 'data' + 29.to_s | Convert int. | Ruby |
{{"id":"value" "status":35}} | {{"id":"value", "status":35}} | Add comma. | JSON |
{{'age':31, 'id' 9}} | {{'age':31, 'id':9}} | Colon missing. | Python |
print 'message' | print 'message'; | Add semicolon. | Perl |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
result = 56 | result=56 | No spaces. | Shell |
fn foo() -> i32 {{ 66 }} | fn foo() -> i32 {{ 66 }} | Correct. | Rust |
x := 78 | x := 78 | Correct. | Go |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
local z = 55 | local z = 55 | Correct. | Lua |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
num == '74' | num === 74 | Use strict equality. | JavaScript |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
raise 'message' | raise Exception('message') | Raise needs an exception class. | Python |
'3' + 74 | 3 + 74 | Avoid string coercion. | JavaScript |
switch(index){{ case 20: break; }} | switch(index){{ case 20: break; default: break; }} | Add default case. | Java |
my @arr = (81,19,4); | my @arr = (81,19,4); | Correct. | Perl |
function baz(b:string){{return b;}} baz(97); | function baz(b:string){{return b;}} baz('hello'); | Pass correct type. | TypeScript |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
def compute
puts 'world'
end | def compute
puts 'world'
end | Correct. | Ruby |
assert result > 44 | assert result > 44 | Correct. | Python |
function bar(): void {{ return 96; }} | function bar(): number {{ return 96; }} | Return type mismatch. | TypeScript |
JOIN profiles ON users.id = profiles.age | JOIN profiles ON users.id = profiles.age | Correct. | SQL |
data[78] | if data.indices.contains(78) {{ data[78] }} | Check index. | Swift |
if bar = 45 | if bar == 45 | Use ==. | Ruby |
$data[38] = 5; | if (isset($data[38])) $data[38] = 5; | Check existence. | PHP |
let temp: i32 = "value"; | let temp: &str = "value"; | Type mismatch. | Rust |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
while a > 42
a -= 1 | while a > 42:
a -= 1 | Colon missing after while. | Python |
val c = 'output' | val c = "output" | Double quotes. | Kotlin |
function baz() {{
return
{{key:'output'}}
}} | function baz() {{
return {{key:'output'}};
}} | Return object on same line. | JavaScript |
#main {{ color: red; }} | #main {{ color: red; }} | Correct. | CSS |
var foo int = 'output' | var foo string = 'output' | Type mismatch. | Go |
foo == '37' | foo === 37 | Use strict equality. | JavaScript |
if (index = 77) | if (index == 77) | Use ==. | C++ |
disp('message') | disp('message') | Correct. | MATLAB |
try {{ throw 'world'; }} catch(e) {{}} | try {{ throw new Error('world'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
int[] arr = new int[9];
arr[9] = 5; | int[] arr = new int[9];
if (9 < arr.length) arr[9] = 5; | Check bounds. | Java |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
let mut result=16; let r1=&mut result; let r2=&mut result; | let mut result=16; {{ let r1=&mut result; }} let r2=&mut result; | Only one mutable borrow. | Rust |
println('result') | println("result") | Double quotes. | Scala |
function compute(): void {{ return 81; }} | function compute(): number {{ return 81; }} | Return type mismatch. | TypeScript |
function render(count:string){{return count;}} render(86); | function render(count:string){{return count;}} render('result'); | Pass correct type. | TypeScript |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
if (c = 86) {} | if (c == 86) {} | Use ==. | Dart |
cin >> val
cout << val; | cin >> val;
cout << val; | Add semicolon. | C++ |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
List(97,94,15) | List(97,94,15) | Correct. | Scala |
a > 9 & y < 99 | a > 9 and y < 99 | Use 'and' not '&'. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
fmt.Println 'message' | fmt.Println('message') | Missing parentheses. | Go |
baz | baz() | Add parentheses. | Kotlin |
'data' + 32 | 'data' + str(32) | Can't add int to string. | Python |
int values[55]; values[55]=5; | int values[55]; if(55<55){{}} else values[55]=5; | Bounds check. | C++ |
const http = require('http'); http.createServer((req,res) => res.end('data')).listen(95); | const http = require('http'); http.createServer((req,res) => res.end('data')).listen(95); | Correct. | Node.js |
object Item {{ def main(args: Array[String]) = println("message") }} | object Item {{ def main(args: Array[String]): Unit = println("message") }} | Add return type Unit. | Scala |
if (count) console.log('yes') else console.log('no') | if (count) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
{{"age":"data",}} | {{"age":"data"}} | Remove trailing comma. | JSON |
else
print('output') | else:
print('output') | Colon after else. | Python |
console.log('world' | console.log('world') | Close parenthesis. | JavaScript |
if count = 84 | if count == 84 | Use ==. | Go |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
print('info') | print('info') | Correct. | R |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
var x = 73; | var x = 73; | Correct. | Dart |
values[40] | if values.indices.contains(40) {{ values[40] }} | Check index. | Swift |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
if item = 56 | if item == 56 | Use ==. | MATLAB |
void main() {{ print('output') }} | void main() {{ print('output'); }} | Add semicolon. | Dart |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
<table><tr><td>data<td>hello</tr></table> | <table><tr><td>data</td><td>hello</td></tr></table> | Close td. | HTML |
val bar: Int = 'value' | val bar: String = 'value' | Fix type. | Kotlin |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
let x: Int = 'hello' | let x: String = 'hello' | Fix type. | Swift |
if bar > 66
puts 'world' | if bar > 66
puts 'world'
end | Add 'end'. | Ruby |
'15' + 13 | 15 + 13 | Avoid string coercion. | JavaScript |
DELETE FROM items WHERE age=60 | DELETE FROM items WHERE age=60; | Add semicolon. | SQL |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
<br></br> | <br> | Self-closing. | HTML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
<ul><li>hello<li>test</ul> | <ul><li>hello</li><li>test</li></ul> | Close li. | HTML |
SELECT id role FROM orders; | SELECT id, role FROM orders; | Add comma. | SQL |
47foo = 10 | foo47 = 10 | Variable cannot start with digit. | Python |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
WHERE id = '88' | WHERE id = 88 | Don't quote integer. | SQL |
for i=1,89 do print(i) end | for i=1,89 do print(i) end | Correct. | Lua |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.