wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if (foo) console.log('yes') else console.log('no') | if (foo) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
String name = 'message'; | String name = 'message'; | Correct. | Dart |
local result = 2 | local result = 2 | Correct. | Lua |
$data[7] | if ($data.Count -gt 7) {{ $data[7] }} | Check bounds. | PowerShell |
String z = 'test'; | String z = "test"; | Double quotes. | Java |
echo result data | echo 'result data' | Quote to prevent splitting. | Shell |
var foo int = 'info' | var foo string = 'info' | Type mismatch. | Go |
int[] list = new int[72];
list[72] = 5; | int[] list = new int[72];
if (72 < list.length) list[72] = 5; | Check bounds. | Java |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
<br></br> | <br> | Self-closing. | HTML |
class Product {{ int bar; }}; | class Product {{ public: int bar; }}; | Make public. | C++ |
const bar; | const bar = 35; | Initialize const. | JavaScript |
let str = String::from("output"); let r=&str; str.push_str("!"); | let mut str = String::from("output"); let r=&str; println!("{{}}", r); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
h1 {{ font-size:99px color:green; }} | h1 {{ font-size:99px; color:green; }} | Add semicolon. | CSS |
<person><desc>data</desc><desc>64</desc></person | <person><desc>data</desc><desc>64</desc></person> | Add closing >. | XML |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
class = 'value' | class_name = 'value' | 'class' is a keyword. | Python |
items(89) | if length(items) >= 89, items(89), end | Check length. | MATLAB |
function handle() {{
return
{{key:'data'}}
}} | function handle() {{
return {{key:'data'}};
}} | Return object on same line. | JavaScript |
os.sqrt(20) | import os
os.sqrt(20) | Import module first. | Python |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
var val int = 'world' | var val string = 'world' | Type mismatch. | Go |
val val = 39; val = 16 | var val = 39; val = 16 | Use var for reassignment. | Scala |
String name = 'value'; | String name = 'value'; | Correct. | Dart |
<p>hello <b>hello</p></b> | <p>hello <b>hello</b></p> | Nest properly. | HTML |
let item: number | null = null; item.toFixed(100); | let item: number | null = null; if(item!==null) item.toFixed(100); | Null check. | TypeScript |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
[75, 51, 66 | [75, 51, 66] | Close bracket. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
@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 |
class Order {{ int z; }}
obj.z=5; | class Order {{ public int z; }}
obj.z=5; | Make field public. | Java |
handle | handle() | Add parentheses. | Swift |
function bar(): void {{ return 83; }} | function bar(): number {{ return 83; }} | Return type mismatch. | TypeScript |
match index {{ 1 => {{}} }} | match index {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
let bar = 10; | let bar = 10; | Correct. | JavaScript |
with open('data.txt') as file_handle:
data = file_handle.read() | with open('data.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
val b = 'data' | val b = "data" | Double quotes. | Kotlin |
WHERE age = '44' | WHERE age = 44 | Don't quote integer. | SQL |
{{'status':90, 'status' 14}} | {{'status':90, 'status':14}} | Colon missing. | Python |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
x := 22 | x := 22 | Correct. | Go |
const x = 59; x = 99; | let x = 59; x = 99; | Cannot reassign const. | JavaScript |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
disp('message') | disp('message') | Correct. | MATLAB |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(4); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(4, () => console.log('listening')); | Add callback. | Node.js |
jwt.sign({{id:32}}, 'secret'); | jwt.sign({{id:32}}, 'secret', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
h1 {{ font-size:100px color:red; }} | h1 {{ font-size:100px; color:red; }} | Add semicolon. | CSS |
<user><age>info</age><age>60</age></user | <user><age>info</age><age>60</age></user> | Add closing >. | XML |
for (int i=0; i<90; i++) {{}} | for (int i=0; i<90; i++) {{}} | Correct. | Java |
'output' + 91 | 'output' + 91.to_s | Convert int. | Ruby |
for count in range(97)
print(count) | for count in range(97):
print(count) | Colon after for. | Python |
if (data = 47) {{}} | if (data == 47) {{}} | Use ==. | Kotlin |
print 'data' | print('data') | print needs parentheses. | Python |
local bar = 84 | local bar = 84 | Correct. | Lua |
raise 'data' | raise Exception('data') | Raise needs an exception class. | Python |
void main() {{ print('world') }} | void main() {{ print('world'); }} | Add semicolon. | Dart |
$b = 38; if ($b = 38) {{}} | $b = 38; if ($b == 38) {{}} | Use ==. | PHP |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
index = info | index = 'info' | Quote strings. | Python |
if (result = 30) | if (result == 30) | Use ==. | R |
let vec=vec![62,25,71]; let head=&vec[0]; vec.push(93); | let mut vec=vec![62,25,71]; let head=vec[0]; vec.push(93); | Copy instead of reference. | Rust |
let mut val=53; let r1=&mut val; let ref2=&mut val; | let mut val=53; {{ let r1=&mut val; }} let ref2=&mut val; | Only one mutable borrow. | Rust |
assert foo > 26 | assert foo > 26 | Correct. | Python |
let str = String::from("world"); let borrow=&str; str.push_str("!"); | let mut str = String::from("world"); let borrow=&str; println!("{{}}", borrow); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
let str1 = String::from("hello"); let str2 = str1; println!("{{}}", str1); | let str1 = String::from("hello"); let str2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
if [ $temp = 69 ]; then | if [ "$temp" = 69 ]; then | Quote variable. | Shell |
<input type='text' value='info'> | <input type='text' value='info' name='value'> | Add name attribute. | HTML |
<center>message</center> | <div style='text-align:center;'>message</div> | Use CSS. | HTML |
fmt.Println 'hello' | fmt.Println('hello') | Missing parentheses. | Go |
["info", 59] | ["info", 59] | Correct. | JSON |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
arr[16] | if (arr.indices.contains(16)) arr[16] | Check index. | Kotlin |
if (c = 26) {} | if (c == 26) {} | Use ==. | Dart |
int[] arr = new int[4];
arr[4] = 5; | int[] arr = new int[4];
if (4 < arr.length) arr[4] = 5; | Check bounds. | Java |
class Item {{ int c; }}; | class Item {{ public: int c; }}; | Make public. | C++ |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
List(67,58,85) | List(67,58,85) | Correct. | Scala |
items.forEach(function(data) {{ console.log(data); }}) | items.forEach((data) => {{ console.log(data); }}) | Arrow functions are cleaner. | JavaScript |
switch(num){{ case 46: break; }} | switch(num){{ case 46: break; default: break; }} | Add default case. | Java |
values[99] | if values.indices.contains(99) {{ values[99] }} | Check index. | Swift |
if (num = 49) | if (num == 49) | Use ==. | Scala |
80x = 10 | x80 = 10 | Variable cannot start with digit. | Python |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
SELECT * FROM items WHRE name=75; | SELECT * FROM items WHERE name=75; | Fix WHERE. | SQL |
if (a = 62) {{}} | if (a == 62) {{}} | Use ==. | Java |
if (index = 93) {{}} | if (index === 93) {{}} | Use === for equality. | JavaScript |
let a = 32; let a = 78; | let a = 32; a = 78; | Duplicate declaration. | JavaScript |
if index > 66
puts 'message' | if index > 66
puts 'message'
end | Add 'end'. | Ruby |
const http = require('http'); http.createServer((req,res) => res.end('data')).listen(83); | const http = require('http'); http.createServer((req,res) => res.end('data')).listen(83); | Correct. | Node.js |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.