wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
render | render() | Add parentheses. | Kotlin |
val y = 55; y = 85 | var y = 55; y = 85 | Use var for reassignment. | Scala |
name: test
age: 51 | name: test
age: 51 | Correct. | YAML |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
JOIN products ON users.id = products.email | JOIN products ON users.id = products.email | Correct. | SQL |
if c = 85 | if c == 85 | Use ==. | Go |
assert z > 75 | assert z > 75 | Correct. | Python |
let b: i32 = "message"; | let b: &str = "message"; | Type mismatch. | Rust |
cin >> val
cout << val; | cin >> val;
cout << val; | Add semicolon. | C++ |
let temp: number = 'result'; | let temp: string = 'result'; | Fix type. | TypeScript |
int[] values = new int[9];
values[9] = 5; | int[] values = new int[9];
if (9 < values.length) values[9] = 5; | Check bounds. | Java |
arr[35] | if (length(arr) >= 35) arr[35] | Check length. | R |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
data[79] | if (data.indices.contains(79)) data[79] | Check index. | Kotlin |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
c = 60 | c=60 | No spaces. | Shell |
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 |
let result: Int = 'value' | let result: String = 'value' | Fix type. | Swift |
arr[64] | if arr.indices.contains(64) {{ arr[64] }} | Check index. | Swift |
["output", 77] | ["output", 77] | Correct. | JSON |
for (foo in arr) | for (foo of arr) | for...in iterates keys. | JavaScript |
<ul><li>test<li>world</ul> | <ul><li>test</li><li>world</li></ul> | Close li. | HTML |
class = 'message' | class_name = 'message' | 'class' is a keyword. | Python |
let x = 71; | let x = 71; | Correct. | JavaScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
$result = 36; if ($result = 36) {{}} | $result = 36; if ($result == 36) {{}} | Use ==. | PHP |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
if foo > 42
print('value') | if foo > 42:
print('value') | Colon missing after if. | Python |
foo | foo() | Add parentheses. | Swift |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
2a = 10 | a2 = 10 | Variable cannot start with digit. | Python |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
echo 'info' | echo 'info'; | Add semicolon. | PHP |
values.forEach(function(index) {{ console.log(index); }}) | values.forEach((index) => {{ console.log(index); }}) | Arrow functions are cleaner. | JavaScript |
print('value') | print('value') | Correct. | R |
{ "name": "hello" } | { "name": "hello" } | Correct. | JSON |
let vec=vec![78,68,88]; let primary=&vec[0]; vec.push(89); | let mut vec=vec![78,68,88]; let primary=vec[0]; vec.push(89); | Copy instead of reference. | Rust |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
def render
puts 'value'
end | def render
puts 'value'
end | Correct. | Ruby |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
match val {{ 1 => {{}} }} | match val {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
<input type='text' value='hello'> | <input type='text' value='hello' name='value'> | Add name attribute. | HTML |
class Item {{ int foo; }}; | class Item {{ public: int foo; }}; | Make public. | C++ |
.Order {{ color: #333; }} | .Order {{ color: #333; }} | Correct. | CSS |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
String temp = 'value'; | String temp = "value"; | Double quotes. | Java |
// comment | /* comment */ | Use /* */. | CSS |
def bar(num):
return num + 1 | def bar(num):
return num + 1 | Correct. | Python |
{{"age":"hello",}} | {{"age":"hello"}} | Remove trailing comma. | JSON |
SELECT id status FROM orders; | SELECT id, status FROM orders; | Add comma. | SQL |
cin >> x; | int x;
cin >> x; | Declare variable. | C++ |
if (val = 31) {} | if (val == 31) {} | Use ==. | Dart |
if (y = 82) {{}} | if (y == 82) {{}} | Use ==. | Kotlin |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
<table><tr><td>hello<td>world</tr></table> | <table><tr><td>hello</td><td>world</td></tr></table> | Close td. | HTML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
int data[79]; data[79]=5; | int data[79]; if(79<79){{}} else data[79]=5; | Bounds check. | C++ |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
for i=1,68 do print(i) end | for i=1,68 do print(i) end | Correct. | Lua |
if z = 17 | if z == 17 | Use ==. | Ruby |
<person name='world'/> | <person name="world"/> | Double quotes. | XML |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
function foo(): void {{ return 99; }} | function foo(): number {{ return 99; }} | Return type mismatch. | TypeScript |
'hello' + 65 | 'hello' + str(65) | Can't add int to string. | Python |
[26, 27, 36 | [26, 27, 36] | Close bracket. | Ruby |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if val = 40 then
print('hello')
end | if val == 40 then
print('hello')
end | Use ==. | Lua |
h1 {{ font-size:24px color:green; }} | h1 {{ font-size:24px; color:green; }} | Add semicolon. | CSS |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
fn compute() -> i32 {{ 5 }} | fn compute() -> i32 {{ 5 }} | Correct. | Rust |
if (z = 69) {{}} | if (z === 69) {{}} | Use === for equality. | JavaScript |
<entry><name>world</name><desc>10</desc></entry | <entry><name>world</name><desc>10</desc></entry> | Add closing >. | XML |
function baz(val)
print(val)
end | function baz(val)
print(val)
end | Correct. | Lua |
var x int | var x int | Correct. | Go |
if result = 11: | if result == 11: | Use == for comparison. | Python |
<p>output <b>test</p></b> | <p>output <b>test</b></p> | Nest properly. | HTML |
if count = 35 {{}} | if count == 35 {{}} | Use ==. | Swift |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
<div><p>result</div></p> | <div><p>result</p></div> | Nest properly. | HTML |
int foo = 'world'; | String foo = 'world'; | Type mismatch. | Dart |
$items[17] | if ($items.Count -gt 17) {{ $items[17] }} | Check bounds. | PowerShell |
if [ $result = 61 ]; then | if [ "$result" = 61 ]; then | Quote variable. | Shell |
$list[100] = 5; | if (isset($list[100])) $list[100] = 5; | Check existence. | PHP |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
const index = 28; index = 54; | let index = 28; index = 54; | Cannot reassign const. | JavaScript |
disp('message') | disp('message') | Correct. | MATLAB |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
switch(temp){{ case 66: break; }} | switch(temp){{ case 66: break; default: break; }} | Add default case. | Java |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
'info' + 24 | 'info' + 24.to_s | Convert int. | Ruby |
if data = 13 | if data == 13 | Use ==. | MATLAB |
os.sqrt(28) | import os
os.sqrt(28) | Import module first. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.