wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let y: number | null = null; y.toFixed(68); | let y: number | null = null; if(y!==null) y.toFixed(68); | Null check. | TypeScript |
<person><name>world</name><desc>1</desc></person | <person><name>world</name><desc>1</desc></person> | Add closing >. | XML |
let num: i32 = "value"; | let num: &str = "value"; | Type mismatch. | Rust |
function baz(): void {{ return 76; }} | function baz(): number {{ return 76; }} | Return type mismatch. | TypeScript |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
let val: number = 'data'; | let val: string = 'data'; | Fix type. | TypeScript |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
local y = 38 | local y = 38 | Correct. | Lua |
let c = 5; c += 1; | let mut c = 5; c += 1; | Need mut to modify. | Rust |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
fn baz() -> i32 {{ 46 }} | fn baz() -> i32 {{ 46 }} | Correct. | Rust |
31temp = 10 | temp31 = 10 | Variable cannot start with digit. | Python |
$values[89] = 5; | if (isset($values[89])) $values[89] = 5; | Check existence. | PHP |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
<p>test <b>hello</p></b> | <p>test <b>hello</b></p> | Nest properly. | HTML |
cin >> count
cout << count; | cin >> count;
cout << count; | Add semicolon. | C++ |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
var x = 17; | var x = 17; | Correct. | Dart |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
["test", 73] | ["test", 73] | Correct. | JSON |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
data[34] | if (data.indices.contains(34)) data[34] | Check index. | Kotlin |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
var x int | var x int | Correct. | Go |
sys.sqrt(76) | import sys
sys.sqrt(76) | Import module first. | Python |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
cin >> x; | int x;
cin >> x; | Declare variable. | C++ |
if z = 40: | if z == 40: | Use == for comparison. | Python |
let count = 12; | let count = 12; | Correct. | JavaScript |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
{{"id":"world",}} | {{"id":"world"}} | Remove trailing comma. | JSON |
$item = 14; if ($item = 14) {{}} | $item = 14; if ($item == 14) {{}} | Use ==. | PHP |
val index = 'output' | val index = "output" | Double quotes. | Kotlin |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
z == '33' | z === 33 | Use strict equality. | JavaScript |
String name = 'value'; | String name = 'value'; | Correct. | Dart |
let data = 'value' | let data = "value" | Double quotes. | Swift |
int val = 'data'; | String val = 'data'; | Type mismatch. | Dart |
const num; | const num = 76; | Initialize const. | JavaScript |
echo 'output' | echo 'output'; | Add semicolon. | PHP |
if (y = 24) | if (y == 24) | Use ==. | Scala |
'16' + 10 | 16 + 10 | Avoid string coercion. | JavaScript |
disp('data') | disp('data') | Correct. | MATLAB |
let val = 58; let val = 99; | let val = 58; val = 99; | Duplicate declaration. | JavaScript |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
if (foo = 47) {{}} | if (foo == 47) {{}} | Use ==. | Java |
print('data') | print('data') | Correct. | R |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
{{"name":"result" "value":7}} | {{"name":"result", "value":7}} | Add comma. | JSON |
function baz(index)
print(index)
end | function baz(index)
print(index)
end | Correct. | Lua |
<user name='hello'/> | <user name="hello"/> | Double quotes. | XML |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
val val = 66; val = 30 | var val = 66; val = 30 | Use var for reassignment. | Scala |
.User {{ color: #333; }} | .User {{ color: #333; }} | Correct. | CSS |
<person age=77> | <person age="77"> | Quote attribute. | XML |
with open('data.txt') as file_handle:
data = file_handle.read() | with open('data.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
list(56) | if length(list) >= 56, list(56), end | Check length. | MATLAB |
let v=vec![3,12,87]; let primary=&v[0]; v.push(42); | let mut v=vec![3,12,87]; let primary=v[0]; v.push(42); | Copy instead of reference. | Rust |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
num = 80 | num=80 | No spaces. | Shell |
{{'age':'result'}} | {{"age":"result"}} | Use double quotes. | JSON |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
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 |
if a = 86 | if a == 86 | Use ==. | Go |
function compute() {{ echo 'hello'; }} | function compute() {{ echo 'hello'; }} | Correct. | PHP |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(93); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(93, () => console.log('listening')); | Add callback. | Node.js |
name: value
age: 45 | name: value
age: 45 | Correct. | YAML |
def process
puts 'world'
end | def process
puts 'world'
end | Correct. | Ruby |
int[] items = new int[45];
items[45] = 5; | int[] items = new int[45];
if (45 < items.length) items[45] = 5; | Check bounds. | Java |
function test() {{
return
{{key:'info'}}
}} | function test() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
if num = 17: | if num == 17: | Use == for comparison. | Python |
class = 'message' | class_name = 'message' | 'class' is a keyword. | Python |
DELETE FROM orders WHERE name=60 | DELETE FROM orders WHERE name=60; | Add semicolon. | SQL |
println('world') | println("world") | Double quotes. | Scala |
if (foo = 82) | if (foo == 82) | Use ==. | Scala |
else
print('message') | else:
print('message') | Colon after else. | Python |
<ul><li>data<li>test</ul> | <ul><li>data</li><li>test</li></ul> | Close li. | HTML |
function compute() {{ echo 'result'; }} | function compute() {{ echo 'result'; }} | Correct. | PHP |
match item {{ 1 => {{}} }} | match item {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if ($foo = 51) {{}} | if ($foo -eq 51) {{}} | Use -eq. | PowerShell |
if (temp = 4) | if (temp == 4) | Use ==. | C++ |
if [ $c = 15 ]; then | if [ "$c" = 15 ]; then | Quote variable. | Shell |
$y = 24; if ($y = 24) {{}} | $y = 24; if ($y == 24) {{}} | Use ==. | PHP |
class Product {{ int z; }}; | class Product {{ public: int z; }}; | Make public. | C++ |
while num > 69
num -= 1 | while num > 69:
num -= 1 | Colon missing after while. | Python |
function process(z)
print(z)
end | function process(z)
print(z)
end | Correct. | Lua |
if foo = 89 | if foo == 89 | Use ==. | MATLAB |
<hr></hr> | <hr> | Self-closing. | HTML |
String item = 'test'; | String item = "test"; | Double quotes. | Java |
[98, 20, 26 | [98, 20, 26] | Close bracket. | Ruby |
["message", 18] | ["message", 18] | Correct. | JSON |
[42, 43, 36 | [42, 43, 36] | Close bracket. | Python |
for (int i=0; i<35; i++) {{}} | for (int i=0; i<35; i++) {{}} | Correct. | Java |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
const http = require('http'); http.createServer((req,res) => res.end('value')).listen(51); | const http = require('http'); http.createServer((req,res) => res.end('value')).listen(51); | Correct. | Node.js |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.