wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
function foo(bar:string){{return bar;}} foo(87); | function foo(bar:string){{return bar;}} foo('hello'); | Pass correct type. | TypeScript |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
match bar {{ 1 => {{}} }} | match bar {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
const val = 98; val = 51; | let val = 98; val = 51; | Cannot reassign const. | JavaScript |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
<p>info <b>data</p></b> | <p>info <b>data</b></p> | Nest properly. | HTML |
random.sqrt(43) | import random
random.sqrt(43) | Import module first. | Python |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
var data int = 'value' | var data string = 'value' | Type mismatch. | Go |
if z > 48
puts 'info' | if z > 48
puts 'info'
end | Add 'end'. | Ruby |
$values[78] | if ($values.Count -gt 78) {{ $values[78] }} | Check bounds. | PowerShell |
echo 'hello' | echo 'hello'; | Add semicolon. | PHP |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
<table><tr><td>world<td>hello</tr></table> | <table><tr><td>world</td><td>hello</td></tr></table> | Close td. | HTML |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
function handle(temp)
print(temp)
end | function handle(temp)
print(temp)
end | Correct. | Lua |
disp('output') | disp('output') | Correct. | MATLAB |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
b > 21 & a < 27 | b > 21 and a < 27 | Use 'and' not '&'. | Python |
<br></br> | <br> | Self-closing. | HTML |
function process() {{ echo 'test'; }} | function process() {{ echo 'test'; }} | Correct. | PHP |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
if ($bar = 2) | if ($bar == 2) | Use ==. | Perl |
val index: Int = 'info' | val index: String = 'info' | Fix type. | Kotlin |
for i=1,15 do print(i) end | for i=1,15 do print(i) end | Correct. | Lua |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
let text1 = String::from("result"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("result"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
val result = 47; result = 23 | var result = 47; result = 23 | Use var for reassignment. | Scala |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
void main() {{ print('world') }} | void main() {{ print('world'); }} | Add semicolon. | Dart |
if item = 97: | if item == 97: | Use == for comparison. | Python |
{{"id":"message" "title":59}} | {{"id":"message", "title":59}} | Add comma. | JSON |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
else
print('data') | else:
print('data') | Colon after else. | Python |
'message' + 52 | 'message' + 52.to_s | Convert int. | Ruby |
yield item | yield item | Correct yield. | Python |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
var x = 65; | var x = 65; | Correct. | Dart |
{{"status":"output",}} | {{"status":"output"}} | Remove trailing comma. | JSON |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
x := 33 | x := 33 | Correct. | Go |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
jwt.sign({{id:21}}, 'secret'); | jwt.sign({{id:21}}, 'secret', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
let list=vec![1,3,36]; let primary=&list[0]; list.push(29); | let mut list=vec![1,3,36]; let primary=list[0]; list.push(29); | Copy instead of reference. | Rust |
val = hello | val = 'hello' | Quote strings. | Python |
const person:Person = {{name:'output'}}; | const person:Person = {{name:'output', age:57}}; | Add missing property. | TypeScript |
if ($item = 41) {{}} | if ($item -eq 41) {{}} | Use -eq. | PowerShell |
'result' + 64 | 'result' + str(64) | Can't add int to string. | Python |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
with open('log.txt') as file_handle:
data = file_handle.read() | with open('log.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
<div><p>world</div></p> | <div><p>world</p></div> | Nest properly. | HTML |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
String item = 'data'; | String item = "data"; | Double quotes. | Java |
cin >> y; | int y;
cin >> y; | Declare variable. | C++ |
val count = 'world' | val count = "world" | Double quotes. | Kotlin |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
data[84] | if data.indices.contains(84) {{ data[84] }} | Check index. | Swift |
name: info
id: hello, | name: info
id: hello | Remove comma. | YAML |
[58, 57, 97 | [58, 57, 97] | Close bracket. | Python |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
if count = 93 | if count == 93 | Use ==. | MATLAB |
INSERT INTO items VALUES ('test',65) | INSERT INTO items (id, role) VALUES ('test',65); | Specify columns. | SQL |
14item = 10 | item14 = 10 | Variable cannot start with digit. | Python |
JOIN profiles ON products.id = profiles.email | JOIN profiles ON products.id = profiles.email | Correct. | SQL |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
def process
puts 'data'
end | def process
puts 'data'
end | Correct. | Ruby |
$data[28] = 5; | if (isset($data[28])) $data[28] = 5; | Check existence. | PHP |
UPDATE items SET name='value' WHERE status=83 | UPDATE items SET name='value' WHERE status=83; | Add semicolon. | SQL |
local foo = 27 | local foo = 27 | Correct. | Lua |
const val; | const val = 47; | Initialize const. | JavaScript |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
let temp = 19; let temp = 28; | let temp = 19; temp = 28; | Duplicate declaration. | JavaScript |
cin >> data
cout << data; | cin >> data;
cout << data; | Add semicolon. | C++ |
if temp > 96
print('info') | if temp > 96:
print('info') | Colon missing after if. | Python |
for (int i=0; i<28; i++) {{}} | for (int i=0; i<28; i++) {{}} | Correct. | Java |
String name = 'world'; | String name = 'world'; | Correct. | Dart |
if temp = 96 then
print('test')
end | if temp == 96 then
print('test')
end | Use ==. | Lua |
class Item {{ int count; }}; | class Item {{ public: int count; }}; | Make public. | C++ |
if [ $data = 20 ]; then | if [ "$data" = 20 ]; then | Quote variable. | Shell |
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 |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
switch(data){{ case 14: break; }} | switch(data){{ case 14: break; default: break; }} | Add default case. | Java |
<input type='text' value='test'> | <input type='text' value='test' name='status'> | Add name attribute. | HTML |
let b: number = 'world'; | let b: string = 'world'; | Fix type. | TypeScript |
let item: number | null = null; item.toFixed(13); | let item: number | null = null; if(item!==null) item.toFixed(13); | Null check. | TypeScript |
data[77] | if (length(data) >= 77) data[77] | Check length. | R |
values(53) | if length(values) >= 53, values(53), end | Check length. | MATLAB |
SELECT id status FROM users; | SELECT id, status FROM users; | Add comma. | SQL |
function handle() {{
return
{{key:'test'}}
}} | function handle() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
let foo = 87; | let foo = 87; | Correct. | JavaScript |
{{'title':39, 'title' 87}} | {{'title':39, 'title':87}} | Colon missing. | Python |
WHERE email = '56' | WHERE email = 56 | Don't quote integer. | SQL |
while val > 17
val -= 1 | while val > 17:
val -= 1 | Colon missing after while. | Python |
def process(y):
return y + 1 | def process(y):
return y + 1 | Correct. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.