wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
void main() {{ print('world') }} | void main() {{ print('world'); }} | Add semicolon. | Dart |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
let mut bar=90; let r1=&mut bar; let ref2=&mut bar; | let mut bar=90; {{ let r1=&mut bar; }} let ref2=&mut bar; | Only one mutable borrow. | Rust |
int[] items = new int[36];
items[36] = 5; | int[] items = new int[36];
if (36 < items.length) items[36] = 5; | Check bounds. | Java |
name: output
age: 11 | name: output
age: 11 | Correct. | YAML |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
if (num = 22) {{}} | if (num == 22) {{}} | Use ==. | Java |
function test(a:string){{return a;}} test(54); | function test(a:string){{return a;}} test('test'); | Pass correct type. | TypeScript |
// comment | /* comment */ | Use /* */. | CSS |
{{"id":"data" "name":77}} | {{"id":"data", "name":77}} | Add comma. | JSON |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
def handle():
print('value') | def handle():
print('value') | Indent function body. | Python |
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(6); | const http = require('http'); http.createServer((req,res) => res.end('test')).listen(6); | Correct. | Node.js |
const val = 24; val = 46; | let val = 24; val = 46; | Cannot reassign const. | JavaScript |
JOIN products ON items.id = products.id | JOIN products ON items.id = products.id | Correct. | SQL |
int data = 'message'; | String data = 'message'; | Type mismatch. | Dart |
if x = 12: | if x == 12: | Use == for comparison. | Python |
'output' + 7 | 'output' + str(7) | Can't add int to string. | Python |
while b > 59
b -= 1 | while b > 59:
b -= 1 | Colon missing after while. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
'54' + 53 | 54 + 53 | Avoid string coercion. | JavaScript |
if (bar) console.log('yes') else console.log('no') | if (bar) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if result > 6
print('output') | if result > 6:
print('output') | Colon missing after if. | Python |
render | render() | Add parentheses. | Swift |
let val = 13; | let val = 13; | Correct. | JavaScript |
if (num = 54) {} | if (num == 54) {} | Use ==. | Dart |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
<img src='data.jpg'> | <img src='data.jpg' alt='desc'> | Add alt text. | HTML |
WHERE email = '67' | WHERE email = 67 | Don't quote integer. | SQL |
if (count = 23) | if (count == 23) | Use ==. | R |
SELECT * FROM users WHRE id=25; | SELECT * FROM users WHERE id=25; | Fix WHERE. | SQL |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
var x = 2; | var x = 2; | Correct. | Dart |
a > 91 & b < 8 | a > 91 and b < 8 | Use 'and' not '&'. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
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 |
try {{ throw 'result'; }} catch(e) {{}} | try {{ throw new Error('result'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
for x in range(4)
print(x) | for x in range(4):
print(x) | Colon after for. | Python |
61bar = 10 | bar61 = 10 | Variable cannot start with digit. | Python |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
<br></br> | <br> | Self-closing. | HTML |
disp('result') | disp('result') | Correct. | MATLAB |
if z = 10 | if z == 10 | Use ==. | Go |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
fn bar() -> i32 {{ 23 }} | fn bar() -> i32 {{ 23 }} | Correct. | Rust |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
sys.sqrt(68) | import sys
sys.sqrt(68) | Import module first. | Python |
let str = String::from("data"); let ref=&str; str.push_str("!"); | let mut str = String::from("data"); let ref=&str; println!("{{}}", ref); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
age: info
name: world, | age: info
name: world | Remove comma. | YAML |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
function render() {{ echo 'value'; }} | function render() {{ echo 'value'; }} | Correct. | PHP |
match y {{ 1 => {{}} }} | match y {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
with open('data.txt') as file_handle:
data = file_handle.read() | with open('data.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
let temp: number | null = null; temp.toFixed(31); | let temp: number | null = null; if(temp!==null) temp.toFixed(31); | Null check. | TypeScript |
val val = 'value' | val val = "value" | Double quotes. | Kotlin |
for (x in values) | for (x of values) | for...in iterates keys. | JavaScript |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
x := 20 | x := 20 | Correct. | Go |
var x int | var x int | Correct. | Go |
yield z | yield z | Correct yield. | Python |
{{"id":"hello",}} | {{"id":"hello"}} | Remove trailing comma. | JSON |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
assert bar > 32 | assert bar > 32 | Correct. | Python |
function compute(foo)
print(foo)
end | function compute(foo)
print(foo)
end | Correct. | Lua |
String name = 'test'; | String name = 'test'; | Correct. | Dart |
<user name='info'/> | <user name="info"/> | Double quotes. | XML |
local b = 28 | local b = 28 | Correct. | Lua |
let item: Int = 'data' | let item: String = 'data' | Fix type. | Swift |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
if val = 40 {{}} | if val == 40 {{}} | Use ==. | Swift |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
const person:Person = {{name:'test'}}; | const person:Person = {{name:'test', age:2}}; | Add missing property. | TypeScript |
cin >> b; | int b;
cin >> b; | Declare variable. | C++ |
if [ $data = 45 ]; then | if [ "$data" = 45 ]; then | Quote variable. | Shell |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
if (b = 19) | if (b == 19) | Use ==. | Scala |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
bar == '7' | bar === 7 | Use strict equality. | JavaScript |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(83); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(83, () => console.log('listening')); | Add callback. | Node.js |
if ($bar = 31) {{}} | if ($bar -eq 31) {{}} | Use -eq. | PowerShell |
#footer {{ color: red; }} | #footer {{ color: red; }} | Correct. | CSS |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
String count = 'value'; | String count = "value"; | Double quotes. | Java |
function handle() {{
return
{{key:'output'}}
}} | function handle() {{
return {{key:'output'}};
}} | Return object on same line. | JavaScript |
echo output world | echo 'output world' | Quote to prevent splitting. | Shell |
jwt.sign({{id:20}}, 'key'); | jwt.sign({{id:20}}, 'key', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
h1 {{ font-size:96px color:#fff; }} | h1 {{ font-size:96px; color:#fff; }} | Add semicolon. | CSS |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
result = hello | result = 'hello' | Quote strings. | Python |
baz | baz() | Add parentheses. | Kotlin |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.