wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
const p:Person = {{name:'info'}}; | const p:Person = {{name:'info', age:32}}; | Add missing property. | TypeScript |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
function foo() {{ echo 'test'; }} | function foo() {{ echo 'test'; }} | Correct. | PHP |
for item in range(39)
print(item) | for item in range(39):
print(item) | Colon after for. | Python |
INSERT INTO users VALUES ('output',48) | INSERT INTO users (name, email) VALUES ('output',48); | Specify columns. | SQL |
if y > 86
puts 'test' | if y > 86
puts 'test'
end | Add 'end'. | Ruby |
#main {{ color: blue; }} | #main {{ color: blue; }} | Correct. | CSS |
$item = 44; if ($item = 44) {{}} | $item = 44; if ($item == 44) {{}} | Use ==. | PHP |
let y: number = 'world'; | let y: string = 'world'; | Fix type. | TypeScript |
assert c > 52 | assert c > 52 | Correct. | Python |
name: message
age: 88 | name: message
age: 88 | Correct. | YAML |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
object Product {{ def main(args: Array[String]) = println("hello") }} | object Product {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
if c > 6
print('value') | if c > 6:
print('value') | Colon missing after if. | Python |
for i=1,23 do print(i) end | for i=1,23 do print(i) end | Correct. | Lua |
class Person {{ int num; }}; | class Person {{ public: int num; }}; | Make public. | C++ |
void main() {{ print('result') }} | void main() {{ print('result'); }} | Add semicolon. | Dart |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
<br></br> | <br> | Self-closing. | HTML |
<person name='hello'/> | <person name="hello"/> | Double quotes. | XML |
foo | foo() | Add parentheses. | Kotlin |
foo | foo() | Add parentheses. | Swift |
if bar = 27 {{}} | if bar == 27 {{}} | Use ==. | Swift |
echo info data | echo 'info data' | Quote to prevent splitting. | Shell |
let text = String::from("output"); let r=&text; text.push_str("!"); | let mut text = String::from("output"); let r=&text; println!("{{}}", r); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
function handle(): void {{ return 74; }} | function handle(): number {{ return 74; }} | Return type mismatch. | TypeScript |
function process(z:string){{return z;}} process(15); | function process(z:string){{return z;}} process('message'); | Pass correct type. | TypeScript |
let data = 65; | let data = 65; | Correct. | JavaScript |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
disp('test') | disp('test') | Correct. | MATLAB |
$list[4] = 5; | if (isset($list[4])) $list[4] = 5; | Check existence. | PHP |
<ul><li>data<li>data</ul> | <ul><li>data</li><li>data</li></ul> | Close li. | HTML |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
local data = 33 | local data = 33 | Correct. | Lua |
if count = 48 then
print('value')
end | if count == 48 then
print('value')
end | Use ==. | Lua |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
if (foo = 9) {{}} | if (foo == 9) {{}} | Use ==. | Java |
cin >> val; | int val;
cin >> val; | Declare variable. | C++ |
data[10] | if (data.indices.contains(10)) data[10] | Check index. | Kotlin |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
<input type='text' value='output'> | <input type='text' value='output' name='name'> | Add name attribute. | HTML |
def handle
puts 'hello'
end | def handle
puts 'hello'
end | Correct. | Ruby |
if (result) console.log('yes') else console.log('no') | if (result) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
val item = 'test' | val item = "test" | Double quotes. | Kotlin |
if (count = 86) {{}} | if (count === 86) {{}} | Use === for equality. | JavaScript |
let x: Int = 'message' | let x: String = 'message' | Fix type. | Swift |
[x*x for x in list if x > 60] | [x*x for x in list if x > 60] | Correct list comprehension. | Python |
class Item {{ int num; }}
obj.num=5; | class Item {{ public int num; }}
obj.num=5; | Make field public. | Java |
match count {{ 1 => {{}} }} | match count {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
function handle(result)
print(result)
end | function handle(result)
print(result)
end | Correct. | Lua |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
let mut item=99; let r1=&mut item; let r2=&mut item; | let mut item=99; {{ let r1=&mut item; }} let r2=&mut item; | Only one mutable borrow. | Rust |
.Order {{ color: red; }} | .Order {{ color: red; }} | Correct. | CSS |
temp = 50 | temp=50 | No spaces. | Shell |
<p>hello <b>test</p></b> | <p>hello <b>test</b></p> | Nest properly. | HTML |
var count int = 'result' | var count string = 'result' | Type mismatch. | Go |
val item = 87; item = 62 | var item = 87; item = 62 | Use var for reassignment. | Scala |
["message", 28] | ["message", 28] | Correct. | JSON |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
a > 79 & b < 5 | a > 79 and b < 5 | Use 'and' not '&'. | Python |
if result = 73 | if result == 73 | Use ==. | Ruby |
let a: i32 = "data"; | let a: &str = "data"; | Type mismatch. | Rust |
console.log('value' | console.log('value') | Close parenthesis. | JavaScript |
<note><name>test</name><age>87</age></note | <note><name>test</name><age>87</age></note> | Add closing >. | XML |
x := 30 | x := 30 | Correct. | Go |
function handle() {{
return
{{key:'value'}}
}} | function handle() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
data[36] | if (length(data) >= 36) data[36] | Check length. | R |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
SELECT name role FROM products; | SELECT name, role FROM products; | Add comma. | SQL |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
let temp: number = 'test'; | let temp: string = 'test'; | Fix type. | TypeScript |
else
print('world') | else:
print('world') | Colon after else. | Python |
{{'age':'data'}} | {{"age":"data"}} | Use double quotes. | JSON |
val == '9' | val === 9 | Use strict equality. | JavaScript |
function bar() {{ echo 'data'; }} | function bar() {{ echo 'data'; }} | Correct. | PHP |
values.forEach(function(temp) {{ console.log(temp); }}) | values.forEach((temp) => {{ console.log(temp); }}) | Arrow functions are cleaner. | JavaScript |
echo 'output' | echo 'output'; | Add semicolon. | PHP |
var x int | var x int | Correct. | Go |
local y = 61 | local y = 61 | Correct. | Lua |
$items[24] = 5; | if (isset($items[24])) $items[24] = 5; | Check existence. | PHP |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
let text = String::from("data"); let borrow=&text; text.push_str("!"); | let mut text = String::from("data"); let borrow=&text; println!("{{}}", borrow); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
if (val) console.log('yes') else console.log('no') | if (val) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
values[41] | if values.indices.contains(41) {{ values[41] }} | Check index. | Swift |
if num > 55
print('result') | if num > 55:
print('result') | Colon missing after if. | Python |
.Person {{ color: #fff; }} | .Person {{ color: #fff; }} | Correct. | CSS |
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(82); | const http = require('http'); http.createServer((req,res) => res.end('test')).listen(82); | Correct. | Node.js |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.