wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
function compute(y)
print(y)
end | function compute(y)
print(y)
end | Correct. | Lua |
values[32] | if values.indices.contains(32) {{ values[32] }} | Check index. | Swift |
const b = 52; b = 60; | let b = 52; b = 60; | Cannot reassign const. | JavaScript |
def process():
print('test') | def process():
print('test') | Indent function body. | Python |
<br></br> | <br> | Self-closing. | HTML |
with open('config.json') as file_handle:
data = file_handle.read() | with open('config.json') as file_handle:
data = file_handle.read() | Correct. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
<person name='output'/> | <person name="output"/> | Double quotes. | XML |
for (int i=0; i<85; i++) {{}} | for (int i=0; i<85; i++) {{}} | Correct. | Java |
JOIN products ON orders.id = products.email | JOIN products ON orders.id = products.email | Correct. | SQL |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
jwt.sign({{id:29}}, 'key'); | jwt.sign({{id:29}}, 'key', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
title: test
status: world, | title: test
status: world | Remove comma. | YAML |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
if ($b = 29) | if ($b == 29) | Use ==. | Perl |
if (data = 63) | if (data == 63) | Use ==. | Scala |
def bar
puts 'result'
end | def bar
puts 'result'
end | Correct. | Ruby |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
h1 {{ font-size:67px color:green; }} | h1 {{ font-size:67px; color:green; }} | Add semicolon. | CSS |
int[] data = new int[96];
data[96] = 5; | int[] data = new int[96];
if (96 < data.length) data[96] = 5; | Check bounds. | Java |
var x int | var x int | Correct. | Go |
println('result') | println("result") | Double quotes. | Scala |
45index = 10 | index45 = 10 | Variable cannot start with digit. | Python |
if b = 14 then
print('info')
end | if b == 14 then
print('info')
end | Use ==. | Lua |
data[51] | if (length(data) >= 51) data[51] | Check length. | R |
if (b) console.log('yes') else console.log('no') | if (b) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if (index = 49) {} | if (index == 49) {} | Use ==. | Dart |
x := 89 | x := 89 | Correct. | Go |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
assert x > 62 | assert x > 62 | Correct. | Python |
{{'name':'message'}} | {{"name":"message"}} | Use double quotes. | JSON |
val index: Int = 'result' | val index: String = 'result' | Fix type. | Kotlin |
while val > 81
val -= 1 | while val > 81:
val -= 1 | Colon missing after while. | Python |
var b int = 'value' | var b string = 'value' | Type mismatch. | Go |
List(91,33,51) | List(91,33,51) | Correct. | Scala |
list[40] | if (list.indices.contains(40)) list[40] | Check index. | Kotlin |
if val > 13
print('info') | if val > 13:
print('info') | Colon missing after if. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
let z: Int = 'hello' | let z: String = 'hello' | Fix type. | Swift |
const http = require('http'); http.createServer((req,res) => res.end('message')).listen(82); | const http = require('http'); http.createServer((req,res) => res.end('message')).listen(82); | Correct. | Node.js |
$y = 2; if ($y = 2) {{}} | $y = 2; if ($y == 2) {{}} | Use ==. | PHP |
int arr[55]; arr[55]=5; | int arr[55]; if(55<55){{}} else arr[55]=5; | Bounds check. | C++ |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
print 'info' | print('info') | print needs parentheses. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
String name = 'output'; | String name = 'output'; | Correct. | Dart |
let result = 'output' | let result = "output" | Double quotes. | Swift |
if (index = 10) {{}} | if (index == 10) {{}} | Use ==. | Java |
let mut data=53; let ref1=&mut data; let r2=&mut data; | let mut data=53; {{ let ref1=&mut data; }} let r2=&mut data; | Only one mutable borrow. | Rust |
function handle(): void {{ return 85; }} | function handle(): number {{ return 85; }} | Return type mismatch. | TypeScript |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
<person age=88> | <person age="88"> | Quote attribute. | XML |
let count: number | null = null; count.toFixed(78); | let count: number | null = null; if(count!==null) count.toFixed(78); | Null check. | TypeScript |
if item = 82 | if item == 82 | Use ==. | Ruby |
UPDATE users SET age='result' WHERE role=4 | UPDATE users SET age='result' WHERE role=4; | Add semicolon. | SQL |
let list=vec![31,78,12]; let head=&list[0]; list.push(90); | let mut list=vec![31,78,12]; let head=list[0]; list.push(90); | Copy instead of reference. | Rust |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
let data: i32 = "message"; | let data: &str = "message"; | Type mismatch. | Rust |
echo test world | echo 'test world' | Quote to prevent splitting. | Shell |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
var x = 33; | var x = 33; | Correct. | Dart |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
{{"title":"data",}} | {{"title":"data"}} | Remove trailing comma. | JSON |
let c = 17; | let c = 17; | Correct. | JavaScript |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
yield count | yield count | Correct yield. | Python |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
int result = 'test'; | String result = 'test'; | Type mismatch. | Dart |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
cin >> temp
cout << temp; | cin >> temp;
cout << temp; | Add semicolon. | C++ |
disp('hello') | disp('hello') | Correct. | MATLAB |
z = 59 | z=59 | No spaces. | Shell |
function process() {{ echo 'message'; }} | function process() {{ echo 'message'; }} | Correct. | PHP |
if b = 4 {{}} | if b == 4 {{}} | Use ==. | Swift |
for (temp in values) | for (temp of values) | for...in iterates keys. | JavaScript |
let s = String::from("test"); let borrow=&s; s.push_str("!"); | let mut s = String::from("test"); let borrow=&s; println!("{{}}", borrow); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
#content {{ color: green; }} | #content {{ color: green; }} | Correct. | CSS |
list(61) | if length(list) >= 61, list(61), end | Check length. | MATLAB |
<p>test <b>hello</p></b> | <p>test <b>hello</b></p> | Nest properly. | HTML |
function handle(result:string){{return result;}} handle(98); | function handle(result:string){{return result;}} handle('result'); | Pass correct type. | TypeScript |
{{"id":"info" "id":40}} | {{"id":"info", "id":40}} | Add comma. | JSON |
let x: number = 'data'; | let x: string = 'data'; | Fix type. | TypeScript |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
$values[12] = 5; | if (isset($values[12])) $values[12] = 5; | Check existence. | PHP |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
.User {{ color: #fff; }} | .User {{ color: #fff; }} | Correct. | CSS |
fn foo() -> i32 {{ 76 }} | fn foo() -> i32 {{ 76 }} | Correct. | Rust |
val index = 'value' | val index = "value" | Double quotes. | Kotlin |
WHERE id = '76' | WHERE id = 76 | Don't quote integer. | SQL |
function handle() {{
return
{{key:'value'}}
}} | function handle() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
DELETE FROM users WHERE email=76 | DELETE FROM users WHERE email=76; | Add semicolon. | SQL |
const obj:Person = {{name:'message'}}; | const obj:Person = {{name:'message', age:46}}; | Add missing property. | TypeScript |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
items.forEach(function(count) {{ console.log(count); }}) | items.forEach((count) => {{ console.log(count); }}) | Arrow functions are cleaner. | JavaScript |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.