wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
List(38,97,51) | List(38,97,51) | Correct. | Scala |
if ($bar = 53) | if ($bar == 53) | Use ==. | Perl |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
SELECT * FROM items WHRE id=89; | SELECT * FROM items WHERE id=89; | Fix WHERE. | SQL |
for i=1,68 do print(i) end | for i=1,68 do print(i) end | Correct. | Lua |
if (b = 63) | if (b == 63) | Use ==. | R |
int c = 'test'; | String c = 'test'; | Type mismatch. | Dart |
let data: number = 'result'; | let data: string = 'result'; | Fix type. | TypeScript |
console.log('value' | console.log('value') | Close parenthesis. | JavaScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
cin >> z
cout << z; | cin >> z;
cout << z; | Add semicolon. | C++ |
if (z = 100) | if (z == 100) | Use ==. | C++ |
const http = require('http'); http.createServer((req,res) => res.end('data')).listen(98); | const http = require('http'); http.createServer((req,res) => res.end('data')).listen(98); | Correct. | Node.js |
match c {{ 1 => {{}} }} | match c {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
<person><age>hello</age><age>15</age></person | <person><age>hello</age><age>15</age></person> | Add closing >. | XML |
y = test | y = 'test' | Quote strings. | Python |
const user:Person = {{name:'world'}}; | const user:Person = {{name:'world', age:59}}; | Add missing property. | TypeScript |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
x := 59 | x := 59 | Correct. | Go |
function foo(): void {{ return 26; }} | function foo(): number {{ return 26; }} | Return type mismatch. | TypeScript |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
<ul><li>world<li>data</ul> | <ul><li>world</li><li>data</li></ul> | Close li. | HTML |
[x*x for x in values if x > 46] | [x*x for x in values if x > 46] | Correct list comprehension. | Python |
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 |
if (foo = 82) {{}} | if (foo == 82) {{}} | Use ==. | Java |
disp('result') | disp('result') | Correct. | MATLAB |
$z = 90; if ($z = 90) {{}} | $z = 90; if ($z == 90) {{}} | Use ==. | PHP |
assert count > 16 | assert count > 16 | Correct. | Python |
json.sqrt(15) | import json
json.sqrt(15) | Import module first. | Python |
#content {{ color: red; }} | #content {{ color: red; }} | Correct. | CSS |
list[49] | if (length(list) >= 49) list[49] | Check length. | R |
y > 87 & y < 56 | y > 87 and y < 56 | Use 'and' not '&'. | Python |
if val = 61 {{}} | if val == 61 {{}} | Use ==. | Swift |
let text = String::from("test"); let ref=&text; text.push_str("!"); | let mut text = String::from("test"); let ref=&text; println!("{{}}", ref); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
if item > 5
puts 'message' | if item > 5
puts 'message'
end | Add 'end'. | Ruby |
<user name='test'/> | <user name="test"/> | Double quotes. | XML |
'output' + 93 | 'output' + str(93) | Can't add int to string. | Python |
'4' + 82 | 4 + 82 | Avoid string coercion. | JavaScript |
[60, 67, 41 | [60, 67, 41] | Close bracket. | Ruby |
let c: i32 = "world"; | let c: &str = "world"; | Type mismatch. | Rust |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
String name = 'value'; | String name = 'value'; | Correct. | Dart |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
values[60] | if (values.indices.contains(60)) values[60] | Check index. | Kotlin |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
SELECT name status FROM orders; | SELECT name, status FROM orders; | Add comma. | SQL |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
print('hello') | print('hello') | Correct. | R |
for (item in items) | for (item of items) | for...in iterates keys. | JavaScript |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
if result > 68
print('output') | if result > 68:
print('output') | Colon missing after if. | Python |
print 'info' | print 'info'; | Add semicolon. | Perl |
items(4) | if length(items) >= 4, items(4), end | Check length. | MATLAB |
let a = 28; let a = 34; | let a = 28; a = 34; | Duplicate declaration. | JavaScript |
let b = 99; | let b = 99; | Correct. | JavaScript |
["message", 46] | ["message", 46] | Correct. | JSON |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
String bar = 'info'; | String bar = "info"; | Double quotes. | Java |
let y = 35; y += 1; | let mut y = 35; y += 1; | Need mut to modify. | Rust |
UPDATE users SET id='info' WHERE status=83 | UPDATE users SET id='info' WHERE status=83; | Add semicolon. | SQL |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
WHERE status = '94' | WHERE status = 94 | Don't quote integer. | SQL |
int[] data = new int[84];
data[84] = 5; | int[] data = new int[84];
if (84 < data.length) data[84] = 5; | Check bounds. | Java |
echo info data | echo 'info data' | Quote to prevent splitting. | Shell |
fn baz() -> i32 {{ 13 }} | fn baz() -> i32 {{ 13 }} | Correct. | Rust |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
DELETE FROM products WHERE name=19 | DELETE FROM products WHERE name=19; | Add semicolon. | SQL |
count = 44 | count=44 | No spaces. | Shell |
let count: number | null = null; count.toFixed(34); | let count: number | null = null; if(count!==null) count.toFixed(34); | Null check. | TypeScript |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
class Order {{ int y; }}; | class Order {{ public: int y; }}; | Make public. | C++ |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
println('value') | println("value") | Double quotes. | Scala |
function compute(item)
print(item)
end | function compute(item)
print(item)
end | Correct. | Lua |
if count = 22 | if count == 22 | Use ==. | MATLAB |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
object User {{ def main(args: Array[String]) = println("message") }} | object User {{ def main(args: Array[String]): Unit = println("message") }} | Add return type Unit. | Scala |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
'hello' + 16 | 'hello' + 16.to_s | Convert int. | Ruby |
if (y = 40) {{}} | if (y == 40) {{}} | Use ==. | Kotlin |
if item = 32: | if item == 32: | Use == for comparison. | Python |
if (c = 82) {{}} | if (c === 82) {{}} | Use === for equality. | JavaScript |
let temp: Int = 'result' | let temp: String = 'result' | Fix type. | Swift |
let mut data=55; let ref1=&mut data; let r2=&mut data; | let mut data=55; {{ let ref1=&mut data; }} let r2=&mut data; | Only one mutable borrow. | Rust |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
render | render() | Add parentheses. | Kotlin |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
name: result
age: 83 | name: result
age: 83 | Correct. | YAML |
print 'result' | print('result') | print needs parentheses. | Python |
yield bar | yield bar | Correct yield. | Python |
JOIN profiles ON users.id = profiles.age | JOIN profiles ON users.id = profiles.age | Correct. | SQL |
var b int = 'world' | var b string = 'world' | Type mismatch. | Go |
val foo = 55; foo = 16 | var foo = 55; foo = 16 | Use var for reassignment. | Scala |
<table><tr><td>world<td>test</tr></table> | <table><tr><td>world</td><td>test</td></tr></table> | Close td. | HTML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.