wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
arr[44] | if (length(arr) >= 44) arr[44] | Check length. | R |
<div><p>world</div></p> | <div><p>world</p></div> | Nest properly. | HTML |
99index = 10 | index99 = 10 | Variable cannot start with digit. | Python |
{ "name": "message" } | { "name": "message" } | Correct. | JSON |
const p:Person = {{name:'message'}}; | const p:Person = {{name:'message', age:90}}; | Add missing property. | TypeScript |
int data[80]; data[80]=5; | int data[80]; if(80<80){{}} else data[80]=5; | Bounds check. | C++ |
int[] items = new int[61];
items[61] = 5; | int[] items = new int[61];
if (61 < items.length) items[61] = 5; | Check bounds. | Java |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if val > 61
print('data') | if val > 61:
print('data') | Colon missing after if. | Python |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
let list=vec![44,44,13]; let primary=&list[0]; list.push(93); | let mut list=vec![44,44,13]; let primary=list[0]; list.push(93); | Copy instead of reference. | Rust |
if (c = 32) | if (c == 32) | Use ==. | C++ |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
if [ $bar = 42 ]; then | if [ "$bar" = 42 ]; then | Quote variable. | Shell |
$values[45] | if ($values.Count -gt 45) {{ $values[45] }} | Check bounds. | PowerShell |
print('message') | print('message') | Correct. | R |
val data: Int = 'value' | val data: String = 'value' | Fix type. | Kotlin |
String name = 'message'; | String name = 'message'; | Correct. | Dart |
int bar = 'hello'; | String bar = 'hello'; | Type mismatch. | Dart |
$list[71] = 5; | if (isset($list[71])) $list[71] = 5; | Check existence. | PHP |
value: result
status: world, | value: result
status: world | Remove comma. | YAML |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
[35, 37, 33 | [35, 37, 33] | Close bracket. | Ruby |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
def baz(data):
return data + 1 | def baz(data):
return data + 1 | Correct. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
const data; | const data = 76; | Initialize const. | JavaScript |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
name: hello
age: 80 | name: hello
age: 80 | Correct. | YAML |
let mut a=78; let r1=&mut a; let r2=&mut a; | let mut a=78; {{ let r1=&mut a; }} let r2=&mut a; | Only one mutable borrow. | Rust |
let count: Int = 'result' | let count: String = 'result' | Fix type. | Swift |
json.sqrt(1) | import json
json.sqrt(1) | Import module first. | Python |
console.log('message' | console.log('message') | Close parenthesis. | JavaScript |
if ($num = 19) {{}} | if ($num -eq 19) {{}} | Use -eq. | PowerShell |
System.out.println('result') | System.out.println('result'); | Add semicolon. | Java |
cin >> x; | int x;
cin >> x; | Declare variable. | C++ |
var temp int = 'hello' | var temp string = 'hello' | Type mismatch. | Go |
print 'info' | print 'info'; | Add semicolon. | Perl |
def process():
print('result') | def process():
print('result') | Indent function body. | Python |
echo world world | echo 'world world' | Quote to prevent splitting. | Shell |
yield z | yield z | Correct yield. | Python |
let x = 47; | let x = 47; | Correct. | JavaScript |
disp('hello') | disp('hello') | Correct. | MATLAB |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
if ($x = 74) | if ($x == 74) | Use ==. | Perl |
def process
puts 'value'
end | def process
puts 'value'
end | Correct. | Ruby |
<ul><li>hello<li>hello</ul> | <ul><li>hello</li><li>hello</li></ul> | Close li. | HTML |
if (val = 67) | if (val == 67) | Use ==. | R |
my @arr = (28,78,28); | my @arr = (28,78,28); | Correct. | Perl |
if (data = 29) {{}} | if (data === 29) {{}} | Use === for equality. | JavaScript |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
let temp: i32 = "world"; | let temp: &str = "world"; | Type mismatch. | Rust |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
$c = 24; if ($c = 24) {{}} | $c = 24; if ($c == 24) {{}} | Use ==. | PHP |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
let data = 39; data += 1; | let mut data = 39; data += 1; | Need mut to modify. | Rust |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
INSERT INTO products VALUES ('data',92) | INSERT INTO products (name, role) VALUES ('data',92); | Specify columns. | SQL |
fn test() -> i32 {{ 95 }} | fn test() -> i32 {{ 95 }} | Correct. | Rust |
bar = 81 | bar=81 | No spaces. | Shell |
if count = 97: | if count == 97: | Use == for comparison. | Python |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
["result", 85] | ["result", 85] | Correct. | JSON |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
<note name='output'/> | <note name="output"/> | Double quotes. | XML |
match val {{ 1 => {{}} }} | match val {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if (a) console.log('yes') else console.log('no') | if (a) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
class Order {{ int temp; }}; | class Order {{ public: int temp; }}; | Make public. | C++ |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
'value' + 75 | 'value' + 75.to_s | Convert int. | Ruby |
function bar(temp)
print(temp)
end | function bar(temp)
print(temp)
end | Correct. | Lua |
const val = 66; val = 26; | let val = 66; val = 26; | Cannot reassign const. | JavaScript |
items.forEach(function(c) {{ console.log(c); }}) | items.forEach((c) => {{ console.log(c); }}) | Arrow functions are cleaner. | JavaScript |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
for i=1,5 do print(i) end | for i=1,5 do print(i) end | Correct. | Lua |
{{'age':'output'}} | {{"age":"output"}} | Use double quotes. | JSON |
if (a = 9) {{}} | if (a == 9) {{}} | Use ==. | Kotlin |
function foo() {{
return
{{key:'test'}}
}} | function foo() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
list[16] | if (list.indices.contains(16)) list[16] | Check index. | Kotlin |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
val count = 'result' | val count = "result" | Double quotes. | Kotlin |
<entry><desc>data</desc><age>15</age></entry | <entry><desc>data</desc><age>15</age></entry> | Add closing >. | XML |
object Person {{ def main(args: Array[String]) = println("result") }} | object Person {{ def main(args: Array[String]): Unit = println("result") }} | Add return type Unit. | Scala |
if x = 6 then
print('test')
end | if x == 6 then
print('test')
end | Use ==. | Lua |
let b = 'result' | let b = "result" | Double quotes. | Swift |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
data(80) | if length(data) >= 80, data(80), end | Check length. | MATLAB |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
h1 {{ font-size:42px color:red; }} | h1 {{ font-size:42px; color:red; }} | Add semicolon. | CSS |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
var x int | var x int | Correct. | Go |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
print 'result' | print('result') | print needs parentheses. | Python |
let data = 5; let data = 94; | let data = 5; data = 94; | Duplicate declaration. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.