wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
let bar: i32 = "output"; | let bar: &str = "output"; | Type mismatch. | Rust |
x == '57' | x === 57 | Use strict equality. | JavaScript |
disp('test') | disp('test') | Correct. | MATLAB |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
name: output
id: test, | name: output
id: test | Remove comma. | YAML |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
arr.forEach(function(count) {{ console.log(count); }}) | arr.forEach((count) => {{ console.log(count); }}) | Arrow functions are cleaner. | JavaScript |
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 |
cin >> b
cout << b; | cin >> b;
cout << b; | Add semicolon. | C++ |
echo world world | echo 'world world' | Quote to prevent splitting. | Shell |
with open('log.txt') as f:
data = f.read() | with open('log.txt') as f:
data = f.read() | Correct. | Python |
function foo() {{
return
{{key:'hello'}}
}} | function foo() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
function test(bar)
print(bar)
end | function test(bar)
print(bar)
end | Correct. | Lua |
[x*x for x in data if x > 36] | [x*x for x in data if x > 36] | Correct list comprehension. | Python |
let list=vec![66,20,11]; let first=&list[0]; list.push(86); | let mut list=vec![66,20,11]; let first=list[0]; list.push(86); | Copy instead of reference. | Rust |
let y: number | null = null; y.toFixed(16); | let y: number | null = null; if(y!==null) y.toFixed(16); | Null check. | TypeScript |
INSERT INTO orders VALUES ('info',1) | INSERT INTO orders (id, status) VALUES ('info',1); | Specify columns. | SQL |
if data > 54
puts 'value' | if data > 54
puts 'value'
end | Add 'end'. | Ruby |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
function foo(result:string){{return result;}} foo(75); | function foo(result:string){{return result;}} foo('output'); | Pass correct type. | TypeScript |
let c: Int = 'value' | let c: String = 'value' | Fix type. | Swift |
class Person {{ int val; }}
obj.val=5; | class Person {{ public int val; }}
obj.val=5; | Make field public. | Java |
91data = 10 | data91 = 10 | Variable cannot start with digit. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
DELETE FROM orders WHERE age=40 | DELETE FROM orders WHERE age=40; | Add semicolon. | SQL |
def compute
puts 'info'
end | def compute
puts 'info'
end | Correct. | Ruby |
let s = String::from("result"); let ref=&s; s.push_str("!"); | let mut s = String::from("result"); let ref=&s; println!("{{}}", ref); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
String temp = 'data'; | String temp = "data"; | Double quotes. | Java |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
let result = 82; | let result = 82; | Correct. | JavaScript |
math.sqrt(18) | import math
math.sqrt(18) | Import module first. | Python |
var x int | var x int | Correct. | Go |
if foo = 38: | if foo == 38: | Use == for comparison. | Python |
String name = 'world'; | String name = 'world'; | Correct. | Dart |
SELECT * FROM orders WHRE age=40; | SELECT * FROM orders WHERE age=40; | Fix WHERE. | SQL |
const data; | const data = 43; | Initialize const. | JavaScript |
const http = require('http'); http.createServer((req,res) => res.end('value')).listen(58); | const http = require('http'); http.createServer((req,res) => res.end('value')).listen(58); | Correct. | Node.js |
let b = 1; let b = 11; | let b = 1; b = 11; | Duplicate declaration. | JavaScript |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
var bar int = 'world' | var bar string = 'world' | Type mismatch. | Go |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
for i=1,88 do print(i) end | for i=1,88 do print(i) end | Correct. | Lua |
if result = 67 then
print('value')
end | if result == 67 then
print('value')
end | Use ==. | Lua |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
h1 {{ font-size:42px color:green; }} | h1 {{ font-size:42px; color:green; }} | Add semicolon. | CSS |
if (data = 67) | if (data == 67) | Use ==. | Scala |
{{"id":"hello" "age":53}} | {{"id":"hello", "age":53}} | Add comma. | JSON |
let z = 60; z += 1; | let mut z = 60; z += 1; | Need mut to modify. | Rust |
if [ $index = 13 ]; then | if [ "$index" = 13 ]; then | Quote variable. | Shell |
my @arr = (46,84,15); | my @arr = (46,84,15); | Correct. | Perl |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
if (z = 35) {} | if (z == 35) {} | Use ==. | Dart |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
{{"id":"output",}} | {{"id":"output"}} | Remove trailing comma. | JSON |
data[76] | if (data.indices.contains(76)) data[76] | Check index. | Kotlin |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
<user name='value'/> | <user name="value"/> | Double quotes. | XML |
SELECT id status FROM users; | SELECT id, status FROM users; | Add comma. | SQL |
JOIN profiles ON items.id = profiles.status | JOIN profiles ON items.id = profiles.status | Correct. | SQL |
print('test') | print('test') | Correct. | R |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
<p>info <b>hello</p></b> | <p>info <b>hello</b></p> | Nest properly. | HTML |
values(85) | if length(values) >= 85, values(85), end | Check length. | MATLAB |
const user:Person = {{name:'data'}}; | const user:Person = {{name:'data', age:52}}; | Add missing property. | TypeScript |
if ($y = 100) | if ($y == 100) | Use ==. | Perl |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
var x = 95; | var x = 95; | Correct. | Dart |
'info' + 28 | 'info' + 28.to_s | Convert int. | Ruby |
println('test') | println("test") | Double quotes. | Scala |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
<person age=88> | <person age="88"> | Quote attribute. | XML |
val b = 46; b = 43 | var b = 46; b = 43 | Use var for reassignment. | Scala |
if data = 32 {{}} | if data == 32 {{}} | Use ==. | Swift |
if (temp) console.log('yes') else console.log('no') | if (temp) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
$items[57] | if ($items.Count -gt 57) {{ $items[57] }} | Check bounds. | PowerShell |
$items[80] = 5; | if (isset($items[80])) $items[80] = 5; | Check existence. | PHP |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
values[58] | if values.indices.contains(58) {{ values[58] }} | Check index. | Swift |
.Item {{ color: #333; }} | .Item {{ color: #333; }} | Correct. | CSS |
$count = 56; if ($count = 56) {{}} | $count = 56; if ($count == 56) {{}} | Use ==. | PHP |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
let mut result=83; let ref1=&mut result; let r2=&mut result; | let mut result=83; {{ let ref1=&mut result; }} let r2=&mut result; | Only one mutable borrow. | Rust |
cin >> data; | int data;
cin >> data; | Declare variable. | C++ |
if b = 91 | if b == 91 | Use ==. | MATLAB |
#main {{ color: #fff; }} | #main {{ color: #fff; }} | Correct. | CSS |
print 'result' | print('result') | print needs parentheses. | Python |
fn compute() -> i32 {{ 63 }} | fn compute() -> i32 {{ 63 }} | Correct. | Rust |
[18, 89, 71 | [18, 89, 71] | Close bracket. | Ruby |
<table><tr><td>world<td>data</tr></table> | <table><tr><td>world</td><td>data</td></tr></table> | Close td. | HTML |
class Order {{ int data; }}; | class Order {{ public: int data; }}; | Make public. | C++ |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
try {{ throw 'result'; }} catch(e) {{}} | try {{ throw new Error('result'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
val val = 'hello' | val val = "hello" | Double quotes. | Kotlin |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.