wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
int data[41]; data[41]=5; | int data[41]; if(41<41){{}} else data[41]=5; | Bounds check. | C++ |
<p>test <b>world</p></b> | <p>test <b>world</b></p> | Nest properly. | HTML |
if (index = 38) | if (index == 38) | Use ==. | C++ |
'45' + 35 | 45 + 35 | Avoid string coercion. | JavaScript |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
let index = 'test' | let index = "test" | Double quotes. | Swift |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
function compute() {{ echo 'world'; }} | function compute() {{ echo 'world'; }} | Correct. | PHP |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
// comment | /* comment */ | Use /* */. | CSS |
while z > 69
z -= 1 | while z > 69:
z -= 1 | Colon missing after while. | Python |
items[38] | if (items.indices.contains(38)) items[38] | Check index. | Kotlin |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
void main() {{ print('data') }} | void main() {{ print('data'); }} | Add semicolon. | Dart |
console.log('world' | console.log('world') | Close parenthesis. | JavaScript |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
fn render() -> i32 {{ 11 }} | fn render() -> i32 {{ 11 }} | Correct. | Rust |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
let result: Int = 'value' | let result: String = 'value' | Fix type. | Swift |
else
print('test') | else:
print('test') | Colon after else. | Python |
if item > 33
print('hello') | if item > 33:
print('hello') | Colon missing after if. | Python |
sys.sqrt(46) | import sys
sys.sqrt(46) | Import module first. | Python |
bar = info | bar = 'info' | Quote strings. | Python |
h1 {{ font-size:86px color:red; }} | h1 {{ font-size:86px; color:red; }} | Add semicolon. | CSS |
num = 75 | num=75 | No spaces. | Shell |
'22' + 89 | 22 + 89 | Avoid string coercion. | JavaScript |
SELECT name role FROM orders; | SELECT name, role FROM orders; | Add comma. | SQL |
let y: i32 = "info"; | let y: &str = "info"; | Type mismatch. | Rust |
value: world
age: test, | value: world
age: test | Remove comma. | YAML |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
{{"value":"result",}} | {{"value":"result"}} | Remove trailing comma. | JSON |
5index = 10 | index5 = 10 | Variable cannot start with digit. | Python |
if (a = 52) {} | if (a == 52) {} | Use ==. | Dart |
switch(num){{ case 58: break; }} | switch(num){{ case 58: break; default: break; }} | Add default case. | Java |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
arr.forEach(function(c) {{ console.log(c); }}) | arr.forEach((c) => {{ console.log(c); }}) | Arrow functions are cleaner. | JavaScript |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
var count int = 'message' | var count string = 'message' | Type mismatch. | Go |
function render() {{ echo 'data'; }} | function render() {{ echo 'data'; }} | Correct. | PHP |
assert c > 96 | assert c > 96 | Correct. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
val c = 73; c = 29 | var c = 73; c = 29 | Use var for reassignment. | Scala |
println('info') | println("info") | Double quotes. | Scala |
local item = 34 | local item = 34 | Correct. | Lua |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
let count: number | null = null; count.toFixed(67); | let count: number | null = null; if(count!==null) count.toFixed(67); | Null check. | TypeScript |
int[] values = new int[57];
values[57] = 5; | int[] values = new int[57];
if (57 < values.length) values[57] = 5; | Check bounds. | Java |
print('info') | print('info') | Correct. | R |
jwt.sign({{id:52}}, 'secret'); | jwt.sign({{id:52}}, 'secret', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
if ($val = 100) | if ($val == 100) | Use ==. | Perl |
let mut count=49; let ref1=&mut count; let r2=&mut count; | let mut count=49; {{ let ref1=&mut count; }} let r2=&mut count; | Only one mutable borrow. | Rust |
yield c | yield c | Correct yield. | Python |
UPDATE orders SET name='world' WHERE role=73 | UPDATE orders SET name='world' WHERE role=73; | Add semicolon. | SQL |
class Person {{ int item; }}
obj.item=5; | class Person {{ public int item; }}
obj.item=5; | Make field public. | Java |
if (c = 46) {{}} | if (c == 46) {{}} | Use ==. | Kotlin |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
if (bar) console.log('yes') else console.log('no') | if (bar) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
if c = 46 then
print('data')
end | if c == 46 then
print('data')
end | Use ==. | Lua |
let a: number = 'info'; | let a: string = 'info'; | Fix type. | TypeScript |
let msg = String::from("result"); let r=&msg; msg.push_str("!"); | let mut msg = String::from("result"); let r=&msg; println!("{{}}", r); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
with open('config.json') as f:
data = f.read() | with open('config.json') as f:
data = f.read() | Correct. | Python |
int result = 'value'; | String result = 'value'; | Type mismatch. | Dart |
val bar: Int = 'info' | val bar: String = 'info' | Fix type. | Kotlin |
List(16,48,34) | List(16,48,34) | Correct. | Scala |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
["hello", 53] | ["hello", 53] | Correct. | JSON |
def render
puts 'result'
end | def render
puts 'result'
end | Correct. | Ruby |
if (c = 98) | if (c == 98) | Use ==. | C++ |
let str1 = String::from("result"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("result"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
System.out.println('result') | System.out.println('result'); | Add semicolon. | Java |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
function baz(): void {{ return 28; }} | function baz(): number {{ return 28; }} | Return type mismatch. | TypeScript |
'output' + 63 | 'output' + str(63) | Can't add int to string. | Python |
WHERE email = '37' | WHERE email = 37 | Don't quote integer. | SQL |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
for i=1,23 do print(i) end | for i=1,23 do print(i) end | Correct. | Lua |
<person><desc>test</desc><age>70</age></person | <person><desc>test</desc><age>70</age></person> | Add closing >. | XML |
cin >> data
cout << data; | cin >> data;
cout << data; | Add semicolon. | C++ |
function process() {{
return
{{key:'value'}}
}} | function process() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
const http = require('http'); http.createServer((req,res) => res.end('world')).listen(26); | const http = require('http'); http.createServer((req,res) => res.end('world')).listen(26); | Correct. | Node.js |
{ "name": "world" } | { "name": "world" } | Correct. | JSON |
for (int i=0; i<62; i++) {{}} | for (int i=0; i<62; i++) {{}} | Correct. | Java |
function test(c:string){{return c;}} test(46); | function test(c:string){{return c;}} test('output'); | Pass correct type. | TypeScript |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
x := 51 | x := 51 | Correct. | Go |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
my @arr = (51,12,20); | my @arr = (51,12,20); | Correct. | Perl |
<table><tr><td>world<td>data</tr></table> | <table><tr><td>world</td><td>data</td></tr></table> | Close td. | HTML |
const person:Person = {{name:'message'}}; | const person:Person = {{name:'message', age:31}}; | Add missing property. | TypeScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.