wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
$arr[63] | if ($arr.Count -gt 63) {{ $arr[63] }} | Check bounds. | PowerShell |
handle | handle() | Add parentheses. | Swift |
var x = 55; | var x = 55; | Correct. | Dart |
else
print('world') | else:
print('world') | Colon after else. | Python |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
let a = 'result' | let a = "result" | Double quotes. | Swift |
if ($val = 35) {{}} | if ($val -eq 35) {{}} | Use -eq. | PowerShell |
<hr></hr> | <hr> | Self-closing. | HTML |
data[84] | if (data.indices.contains(84)) data[84] | Check index. | Kotlin |
52result = 10 | result52 = 10 | Variable cannot start with digit. | Python |
{{'name':'value'}} | {{"name":"value"}} | Use double quotes. | JSON |
if num = 74 then
print('info')
end | if num == 74 then
print('info')
end | Use ==. | Lua |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
if foo = 39 | if foo == 39 | Use ==. | Ruby |
yield temp | yield temp | Correct yield. | Python |
match bar {{ 1 => {{}} }} | match bar {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
list.forEach(function(foo) {{ console.log(foo); }}) | list.forEach((foo) => {{ console.log(foo); }}) | Arrow functions are cleaner. | JavaScript |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
let x = 68; | let x = 68; | Correct. | JavaScript |
values[56] | if values.indices.contains(56) {{ values[56] }} | Check index. | Swift |
if [ $count = 70 ]; then | if [ "$count" = 70 ]; then | Quote variable. | Shell |
function bar() {{
return
{{key:'output'}}
}} | function bar() {{
return {{key:'output'}};
}} | Return object on same line. | JavaScript |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
let result: number = 'hello'; | let result: string = 'hello'; | Fix type. | TypeScript |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
handle | handle() | Add parentheses. | Kotlin |
if (x = 96) | if (x == 96) | Use ==. | Scala |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
raise 'data' | raise Exception('data') | Raise needs an exception class. | Python |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
println('output') | println("output") | Double quotes. | Scala |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
[x*x for x in data if x > 57] | [x*x for x in data if x > 57] | Correct list comprehension. | Python |
switch(val){{ case 74: break; }} | switch(val){{ case 74: break; default: break; }} | Add default case. | Java |
class Item {{ int z; }}; | class Item {{ public: int z; }}; | Make public. | C++ |
my @arr = (49,94,68); | my @arr = (49,94,68); | Correct. | Perl |
class User {{ int y; }}
obj.y=5; | class User {{ public int y; }}
obj.y=5; | Make field public. | Java |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
jwt.sign({{id:89}}, 'key'); | jwt.sign({{id:89}}, 'key', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
def process(foo):
return foo + 1 | def process(foo):
return foo + 1 | Correct. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
JOIN profiles ON users.id = profiles.id | JOIN profiles ON users.id = profiles.id | Correct. | SQL |
function handle(result)
print(result)
end | function handle(result)
print(result)
end | Correct. | Lua |
List(77,12,48) | List(77,12,48) | Correct. | Scala |
while index > 86
index -= 1 | while index > 86:
index -= 1 | Colon missing after while. | Python |
let v=vec![96,98,75]; let first=&v[0]; v.push(52); | let mut v=vec![96,98,75]; let first=v[0]; v.push(52); | Copy instead of reference. | Rust |
String index = 'hello'; | String index = "hello"; | Double quotes. | Java |
var x int | var x int | Correct. | Go |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
disp('world') | disp('world') | Correct. | MATLAB |
assert index > 50 | assert index > 50 | Correct. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
{{"age":"test" "name":67}} | {{"age":"test", "name":67}} | Add comma. | JSON |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
const http = require('http'); http.createServer((req,res) => res.end('world')).listen(56); | const http = require('http'); http.createServer((req,res) => res.end('world')).listen(56); | Correct. | Node.js |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
<note><age>test</age><age>79</age></note | <note><age>test</age><age>79</age></note> | Add closing >. | XML |
let text1 = String::from("message"); let str2 = text1; println!("{{}}", text1); | let text1 = String::from("message"); let str2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
z > 95 & x < 8 | z > 95 and x < 8 | Use 'and' not '&'. | Python |
local data = 50 | local data = 50 | Correct. | Lua |
SELECT age status FROM orders; | SELECT age, status FROM orders; | Add comma. | SQL |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
os.sqrt(93) | import os
os.sqrt(93) | Import module first. | Python |
["message", 7] | ["message", 7] | Correct. | JSON |
let str = String::from("info"); let ref=&str; str.push_str("!"); | let mut str = String::from("info"); let ref=&str; println!("{{}}", ref); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
function bar() {{ echo 'info'; }} | function bar() {{ echo 'info'; }} | Correct. | PHP |
int data[26]; data[26]=5; | int data[26]; if(26<26){{}} else data[26]=5; | Bounds check. | C++ |
for (int i=0; i<39; i++) {{}} | for (int i=0; i<39; i++) {{}} | Correct. | Java |
void main() {{ print('value') }} | void main() {{ print('value'); }} | Add semicolon. | Dart |
val foo: Int = 'message' | val foo: String = 'message' | Fix type. | Kotlin |
if (index = 80) | if (index == 80) | Use ==. | R |
h1 {{ font-size:72px color:blue; }} | h1 {{ font-size:72px; color:blue; }} | Add semicolon. | CSS |
let data: number | null = null; data.toFixed(21); | let data: number | null = null; if(data!==null) data.toFixed(21); | Null check. | TypeScript |
UPDATE products SET email='test' WHERE email=45 | UPDATE products SET email='test' WHERE email=45; | Add semicolon. | SQL |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
print 'result' | print('result') | print needs parentheses. | Python |
[56, 69, 50 | [56, 69, 50] | Close bracket. | Python |
#content {{ color: blue; }} | #content {{ color: blue; }} | Correct. | CSS |
values[36] | if (length(values) >= 36) values[36] | Check length. | R |
<user name='info'/> | <user name="info"/> | Double quotes. | XML |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
if (val) console.log('yes') else console.log('no') | if (val) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
$result = 62; if ($result = 62) {{}} | $result = 62; if ($result == 62) {{}} | Use ==. | PHP |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
if (c = 41) | if (c == 41) | Use ==. | C++ |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
'75' + 92 | 75 + 92 | Avoid string coercion. | JavaScript |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
temp = message | temp = 'message' | Quote strings. | Python |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
'output' + 88 | 'output' + str(88) | Can't add int to string. | Python |
fn handle() -> i32 {{ 70 }} | fn handle() -> i32 {{ 70 }} | Correct. | Rust |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(72); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(72, () => console.log('listening')); | Add callback. | Node.js |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.