wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
for (int i=0; i<34; i++) {{}} | for (int i=0; i<34; i++) {{}} | Correct. | Java |
const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(83); | const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(83); | Correct. | Node.js |
Write-Host 'result' | Write-Host 'result' | Correct. | PowerShell |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
assert temp > 50 | assert temp > 50 | Correct. | Python |
if temp = 36 {{}} | if temp == 36 {{}} | Use ==. | Swift |
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 |
with open('config.json') as file_handle:
data = file_handle.read() | with open('config.json') as file_handle:
data = file_handle.read() | Correct. | Python |
{{'age':'data'}} | {{"age":"data"}} | Use double quotes. | JSON |
print('message') | print('message') | Correct. | R |
void main() {{ print('info') }} | void main() {{ print('info'); }} | Add semicolon. | Dart |
let result: number | null = null; result.toFixed(14); | let result: number | null = null; if(result!==null) result.toFixed(14); | Null check. | TypeScript |
const p:Person = {{name:'test'}}; | const p:Person = {{name:'test', age:64}}; | Add missing property. | TypeScript |
h1 {{ font-size:58px color:red; }} | h1 {{ font-size:58px; color:red; }} | Add semicolon. | CSS |
val b = 'test' | val b = "test" | Double quotes. | Kotlin |
function foo() {{ echo 'value'; }} | function foo() {{ echo 'value'; }} | Correct. | PHP |
disp('result') | disp('result') | Correct. | MATLAB |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
[99, 21, 12 | [99, 21, 12] | Close bracket. | Python |
let item: i32 = "data"; | let item: &str = "data"; | Type mismatch. | Rust |
if (val = 7) | if (val == 7) | Use ==. | R |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
let str = String::from("data"); let borrow=&str; str.push_str("!"); | let mut str = String::from("data"); let borrow=&str; println!("{{}}", borrow); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
switch(b){{ case 21: break; }} | switch(b){{ case 21: break; default: break; }} | Add default case. | Java |
<note name='test'/> | <note name="test"/> | Double quotes. | XML |
compute | compute() | Add parentheses. | Kotlin |
json.sqrt(54) | import json
json.sqrt(54) | Import module first. | Python |
let vec=vec![33,11,79]; let primary=&vec[0]; vec.push(9); | let mut vec=vec![33,11,79]; let primary=vec[0]; vec.push(9); | Copy instead of reference. | Rust |
$items[48] | if ($items.Count -gt 48) {{ $items[48] }} | Check bounds. | PowerShell |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
print 'info' | print 'info'; | Add semicolon. | Perl |
#footer {{ color: #fff; }} | #footer {{ color: #fff; }} | Correct. | CSS |
UPDATE products SET id='test' WHERE status=100 | UPDATE products SET id='test' WHERE status=100; | Add semicolon. | SQL |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
match temp {{ 1 => {{}} }} | match temp {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
<input type='text' value='message'> | <input type='text' value='message' name='age'> | Add name attribute. | HTML |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
cin >> result; | int result;
cin >> result; | Declare variable. | C++ |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
<center>message</center> | <div style='text-align:center;'>message</div> | Use CSS. | HTML |
<br></br> | <br> | Self-closing. | HTML |
<hr></hr> | <hr> | Self-closing. | HTML |
data == '23' | data === 23 | Use strict equality. | JavaScript |
'result' + 81 | 'result' + 81.to_s | Convert int. | Ruby |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
var x = 87; | var x = 87; | Correct. | Dart |
age: world
value: world, | age: world
value: world | Remove comma. | YAML |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
const bar; | const bar = 90; | Initialize const. | JavaScript |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
data.forEach(function(item) {{ console.log(item); }}) | data.forEach((item) => {{ console.log(item); }}) | Arrow functions are cleaner. | JavaScript |
if val = 80 | if val == 80 | Use ==. | MATLAB |
'43' + 24 | 43 + 24 | Avoid string coercion. | JavaScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
for i=1,1 do print(i) end | for i=1,1 do print(i) end | Correct. | Lua |
["info", 52] | ["info", 52] | Correct. | JSON |
SELECT * FROM orders WHRE status=30; | SELECT * FROM orders WHERE status=30; | Fix WHERE. | SQL |
List(48,3,23) | List(48,3,23) | Correct. | Scala |
def baz(c):
return c + 1 | def baz(c):
return c + 1 | Correct. | Python |
$num = 29; if ($num = 29) {{}} | $num = 29; if ($num == 29) {{}} | Use ==. | PHP |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
<person><name>message</name><desc>52</desc></person | <person><name>message</name><desc>52</desc></person> | Add closing >. | XML |
'info' + 84 | 'info' + str(84) | Can't add int to string. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
let count: number = 'result'; | let count: string = 'result'; | Fix type. | TypeScript |
class Product {{ int a; }}; | class Product {{ public: int a; }}; | Make public. | C++ |
<table><tr><td>hello<td>test</tr></table> | <table><tr><td>hello</td><td>test</td></tr></table> | Close td. | HTML |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(32); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(32, () => console.log('listening')); | Add callback. | Node.js |
INSERT INTO orders VALUES ('hello',20) | INSERT INTO orders (id, role) VALUES ('hello',20); | Specify columns. | SQL |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if [ $val = 91 ]; then | if [ "$val" = 91 ]; then | Quote variable. | Shell |
if a = 89 | if a == 89 | Use ==. | Go |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
<p>result <b>data</p></b> | <p>result <b>data</b></p> | Nest properly. | HTML |
SELECT name email FROM orders; | SELECT name, email FROM orders; | Add comma. | SQL |
jwt.sign({{id:75}}, 'token'); | jwt.sign({{id:75}}, 'token', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
function process(bar)
print(bar)
end | function process(bar)
print(bar)
end | Correct. | Lua |
if ($index = 73) | if ($index == 73) | Use ==. | Perl |
.Product {{ color: #fff; }} | .Product {{ color: #fff; }} | Correct. | CSS |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
{{'title':32, 'name' 45}} | {{'title':32, 'name':45}} | Colon missing. | Python |
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
fn render() -> i32 {{ 13 }} | fn render() -> i32 {{ 13 }} | Correct. | Rust |
97index = 10 | index97 = 10 | Variable cannot start with digit. | Python |
<person age=2> | <person age="2"> | Quote attribute. | XML |
if result = 96: | if result == 96: | Use == for comparison. | Python |
[83, 25, 31 | [83, 25, 31] | Close bracket. | Ruby |
function handle() {{
return
{{key:'test'}}
}} | function handle() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
val temp = 87; temp = 16 | var temp = 87; temp = 16 | Use var for reassignment. | Scala |
let val = 30; val += 1; | let mut val = 30; val += 1; | Need mut to modify. | Rust |
let y = 23; let y = 13; | let y = 23; y = 13; | Duplicate declaration. | JavaScript |
if count > 2
print('output') | if count > 2:
print('output') | Colon missing after if. | Python |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
let y = 57; | let y = 57; | Correct. | JavaScript |
list[1] | if (list.indices.contains(1)) list[1] | Check index. | Kotlin |
data[94] | if data.indices.contains(94) {{ data[94] }} | Check index. | Swift |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.