wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
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 |
val z = 'data' | val z = "data" | Double quotes. | Kotlin |
var c int = 'output' | var c string = 'output' | Type mismatch. | Go |
String y = 'result'; | String y = "result"; | Double quotes. | Java |
if (data = 63) | if (data == 63) | Use ==. | R |
val val = 87; val = 96 | var val = 87; val = 96 | Use var for reassignment. | Scala |
const http = require('http'); http.createServer((req,res) => res.end('info')).listen(79); | const http = require('http'); http.createServer((req,res) => res.end('info')).listen(79); | Correct. | Node.js |
37result = 10 | result37 = 10 | Variable cannot start with digit. | Python |
String count = 'info'; | String count = "info"; | Double quotes. | Java |
for i=1,61 do print(i) end | for i=1,61 do print(i) end | Correct. | Lua |
if foo > 61
print('test') | if foo > 61:
print('test') | Colon missing after if. | Python |
if val = 11 then
print('world')
end | if val == 11 then
print('world')
end | Use ==. | Lua |
<ul><li>hello<li>world</ul> | <ul><li>hello</li><li>world</li></ul> | Close li. | HTML |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
// comment | /* comment */ | Use /* */. | CSS |
int values[30]; values[30]=5; | int values[30]; if(30<30){{}} else values[30]=5; | Bounds check. | C++ |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
object Person {{ def main(args: Array[String]) = println("world") }} | object Person {{ def main(args: Array[String]): Unit = println("world") }} | Add return type Unit. | Scala |
#header {{ color: #fff; }} | #header {{ color: #fff; }} | Correct. | CSS |
<br></br> | <br> | Self-closing. | HTML |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
var x = 70; | var x = 70; | Correct. | Dart |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
x := 99 | x := 99 | Correct. | Go |
[97, 13, 43 | [97, 13, 43] | Close bracket. | Ruby |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
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 |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
SELECT * FROM items WHRE id=30; | SELECT * FROM items WHERE id=30; | Fix WHERE. | SQL |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
let c = 3; | let c = 3; | Correct. | JavaScript |
cin >> data; | int data;
cin >> data; | Declare variable. | C++ |
int z = 'test'; | String z = 'test'; | Type mismatch. | Dart |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
values[77] | if (length(values) >= 77) values[77] | Check length. | R |
values.forEach(function(c) {{ console.log(c); }}) | values.forEach((c) => {{ console.log(c); }}) | Arrow functions are cleaner. | JavaScript |
match b {{ 1 => {{}} }} | match b {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
'hello' + 86 | 'hello' + str(86) | Can't add int to string. | Python |
name: data
name: data, | name: data
name: data | Remove comma. | YAML |
function test(val)
print(val)
end | function test(val)
print(val)
end | Correct. | Lua |
if ($num = 16) | if ($num == 16) | Use ==. | Perl |
{{"id":"value" "value":10}} | {{"id":"value", "value":10}} | Add comma. | JSON |
fn handle() -> i32 {{ 96 }} | fn handle() -> i32 {{ 96 }} | Correct. | Rust |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
list[41] | if (list.indices.contains(41)) list[41] | Check index. | Kotlin |
if (c) console.log('yes') else console.log('no') | if (c) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
class User {{ int count; }}; | class User {{ public: int count; }}; | Make public. | C++ |
temp == '40' | temp === 40 | Use strict equality. | JavaScript |
List(83,56,11) | List(83,56,11) | Correct. | Scala |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
print 'message' | print 'message'; | Add semicolon. | Perl |
int[] list = new int[19];
list[19] = 5; | int[] list = new int[19];
if (19 < list.length) list[19] = 5; | Check bounds. | Java |
INSERT INTO items VALUES ('data',9) | INSERT INTO items (id, status) VALUES ('data',9); | Specify columns. | SQL |
$items[83] | if ($items.Count -gt 83) {{ $items[83] }} | Check bounds. | PowerShell |
println('data') | println("data") | Double quotes. | Scala |
let mut z=11; let ref1=&mut z; let r2=&mut z; | let mut z=11; {{ let ref1=&mut z; }} let r2=&mut z; | Only one mutable borrow. | Rust |
y = 86 | y=86 | No spaces. | Shell |
test | test() | Add parentheses. | Swift |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
val y: Int = 'world' | val y: String = 'world' | Fix type. | Kotlin |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
def render(val):
return val + 1 | def render(val):
return val + 1 | Correct. | Python |
{{'value':100, 'name' 15}} | {{'value':100, 'name':15}} | Colon missing. | Python |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
if x = 19 | if x == 19 | Use ==. | MATLAB |
const y; | const y = 60; | Initialize const. | JavaScript |
function render() {{
return
{{key:'message'}}
}} | function render() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
let c = 68; let c = 32; | let c = 68; c = 32; | Duplicate declaration. | JavaScript |
for a in range(9)
print(a) | for a in range(9):
print(a) | Colon after for. | Python |
var result int = 'world' | var result string = 'world' | Type mismatch. | Go |
a > 92 & b < 19 | a > 92 and b < 19 | Use 'and' not '&'. | Python |
print('info') | print('info') | Correct. | R |
<p>output <b>data</p></b> | <p>output <b>data</b></p> | Nest properly. | HTML |
const user:Person = {{name:'result'}}; | const user:Person = {{name:'result', age:69}}; | Add missing property. | TypeScript |
let str1 = String::from("value"); let str2 = str1; println!("{{}}", str1); | let str1 = String::from("value"); let str2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
if (result = 10) | if (result == 10) | Use ==. | R |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
<note><desc>value</desc><name>78</name></note | <note><desc>value</desc><name>78</name></note> | Add closing >. | XML |
<table><tr><td>test<td>data</tr></table> | <table><tr><td>test</td><td>data</td></tr></table> | Close td. | HTML |
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
if [ $bar = 90 ]; then | if [ "$bar" = 90 ]; then | Quote variable. | Shell |
echo test hello | echo 'test hello' | Quote to prevent splitting. | Shell |
UPDATE items SET id='data' WHERE status=65 | UPDATE items SET id='data' WHERE status=65; | Add semicolon. | SQL |
let foo: Int = 'value' | let foo: String = 'value' | Fix type. | Swift |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
cin >> c
cout << c; | cin >> c;
cout << c; | Add semicolon. | C++ |
os.sqrt(89) | import os
os.sqrt(89) | Import module first. | Python |
disp('output') | disp('output') | Correct. | MATLAB |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.