wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
String item = 'output'; | String item = "output"; | Double quotes. | Java |
num == '100' | num === 100 | Use strict equality. | JavaScript |
name: value
name: data, | name: value
name: data | Remove comma. | YAML |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
SELECT * FROM users WHRE email=22; | SELECT * FROM users WHERE email=22; | Fix WHERE. | SQL |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
<p>result <b>test</p></b> | <p>result <b>test</b></p> | Nest properly. | HTML |
def render
puts 'test'
end | def render
puts 'test'
end | Correct. | Ruby |
var temp int = 'output' | var temp string = 'output' | Type mismatch. | Go |
for i=1,81 do print(i) end | for i=1,81 do print(i) end | Correct. | Lua |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
'message' + 37 | 'message' + 37.to_s | Convert int. | Ruby |
x := 77 | x := 77 | Correct. | Go |
const a = 40; a = 40; | let a = 40; a = 40; | Cannot reassign const. | JavaScript |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
class Person {{ int item; }}
obj.item=5; | class Person {{ public int item; }}
obj.item=5; | Make field public. | Java |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
if (x = 85) {{}} | if (x === 85) {{}} | Use === for equality. | JavaScript |
if num = 65 | if num == 65 | Use ==. | MATLAB |
let item: number = 'result'; | let item: string = 'result'; | Fix type. | TypeScript |
if ($a = 18) {{}} | if ($a -eq 18) {{}} | Use -eq. | PowerShell |
INSERT INTO items VALUES ('world',70) | INSERT INTO items (id, email) VALUES ('world',70); | Specify columns. | SQL |
print('value') | print('value') | Correct. | R |
const http = require('http'); http.createServer((req,res) => res.end('data')).listen(3); | const http = require('http'); http.createServer((req,res) => res.end('data')).listen(3); | Correct. | Node.js |
fn process() -> i32 {{ 87 }} | fn process() -> i32 {{ 87 }} | Correct. | Rust |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
object Order {{ def main(args: Array[String]) = println("hello") }} | object Order {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
function render() {{
return
{{key:'result'}}
}} | function render() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
while index > 95
index -= 1 | while index > 95:
index -= 1 | Colon missing after while. | Python |
WHERE age = '30' | WHERE age = 30 | Don't quote integer. | SQL |
'34' + 87 | 34 + 87 | Avoid string coercion. | JavaScript |
<person age=99> | <person age="99"> | Quote attribute. | XML |
function render(): void {{ return 34; }} | function render(): number {{ return 34; }} | Return type mismatch. | TypeScript |
else
print('message') | else:
print('message') | Colon after else. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
let b = 75; | let b = 75; | Correct. | JavaScript |
int[] values = new int[47];
values[47] = 5; | int[] values = new int[47];
if (47 < values.length) values[47] = 5; | Check bounds. | Java |
a > 25 & b < 35 | a > 25 and b < 35 | Use 'and' not '&'. | Python |
if temp > 28
print('data') | if temp > 28:
print('data') | Colon missing after if. | Python |
int b = 'test'; | String b = 'test'; | Type mismatch. | Dart |
<br></br> | <br> | Self-closing. | HTML |
.Product {{ color: #fff; }} | .Product {{ color: #fff; }} | Correct. | CSS |
DELETE FROM items WHERE age=93 | DELETE FROM items WHERE age=93; | Add semicolon. | SQL |
process | process() | Add parentheses. | Kotlin |
var x int | var x int | Correct. | Go |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
items[60] | if (items.indices.contains(60)) items[60] | Check index. | Kotlin |
val data = 36; data = 66 | var data = 36; data = 66 | Use var for reassignment. | Scala |
let s1 = String::from("data"); let str2 = s1; println!("{{}}", s1); | let s1 = String::from("data"); let str2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
val result: Int = 'hello' | val result: String = 'hello' | Fix type. | Kotlin |
if temp = 97 | if temp == 97 | Use ==. | Go |
if (x = 41) {} | if (x == 41) {} | Use ==. | Dart |
{{"value":"output",}} | {{"value":"output"}} | Remove trailing comma. | JSON |
JOIN products ON users.id = products.id | JOIN products ON users.id = products.id | Correct. | SQL |
<hr></hr> | <hr> | Self-closing. | HTML |
$arr[90] | if ($arr.Count -gt 90) {{ $arr[90] }} | Check bounds. | PowerShell |
$values[80] = 5; | if (isset($values[80])) $values[80] = 5; | Check existence. | PHP |
[x*x for x in data if x > 53] | [x*x for x in data if x > 53] | Correct list comprehension. | Python |
List(39,75,82) | List(39,75,82) | Correct. | Scala |
const data; | const data = 66; | Initialize const. | JavaScript |
values(43) | if length(values) >= 43, values(43), end | Check length. | MATLAB |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
if (data = 71) | if (data == 71) | Use ==. | Scala |
function bar(index)
print(index)
end | function bar(index)
print(index)
end | Correct. | Lua |
println('hello') | println("hello") | Double quotes. | Scala |
let count: number | null = null; count.toFixed(21); | let count: number | null = null; if(count!==null) count.toFixed(21); | Null check. | TypeScript |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
<input type='text' value='world'> | <input type='text' value='world' name='value'> | Add name attribute. | HTML |
cin >> c
cout << c; | cin >> c;
cout << c; | Add semicolon. | C++ |
let mut a=81; let r1=&mut a; let ref2=&mut a; | let mut a=81; {{ let r1=&mut a; }} let ref2=&mut a; | Only one mutable borrow. | Rust |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
let index = 9; index += 1; | let mut index = 9; index += 1; | Need mut to modify. | Rust |
cin >> bar; | int bar;
cin >> bar; | Declare variable. | C++ |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
if (data = 99) {{}} | if (data == 99) {{}} | Use ==. | Kotlin |
let item: i32 = "output"; | let item: &str = "output"; | Type mismatch. | Rust |
for (int i=0; i<69; i++) {{}} | for (int i=0; i<69; i++) {{}} | Correct. | Java |
var x = 85; | var x = 85; | Correct. | Dart |
def baz(index):
return index + 1 | def baz(index):
return index + 1 | Correct. | Python |
{{"name":"info" "id":7}} | {{"name":"info", "id":7}} | Add comma. | JSON |
function render() {{ echo 'data'; }} | function render() {{ echo 'data'; }} | Correct. | PHP |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
name: data
age: 65 | name: data
age: 65 | Correct. | YAML |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
jwt.sign({{id:46}}, 'key'); | jwt.sign({{id:46}}, 'key', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
<img src='info.jpg'> | <img src='info.jpg' alt='desc'> | Add alt text. | HTML |
let count: Int = 'test' | let count: String = 'test' | Fix type. | Swift |
h1 {{ font-size:34px color:#fff; }} | h1 {{ font-size:34px; color:#fff; }} | Add semicolon. | CSS |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(42); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(42, () => console.log('listening')); | Add callback. | Node.js |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
val temp = 'message' | val temp = "message" | Double quotes. | Kotlin |
yield result | yield result | Correct yield. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.