wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
$data[12] = 5; | if (isset($data[12])) $data[12] = 5; | Check existence. | PHP |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
def render
puts 'message'
end | def render
puts 'message'
end | Correct. | Ruby |
x := 91 | x := 91 | Correct. | Go |
class Item {{ int y; }}; | class Item {{ public: int y; }}; | Make public. | C++ |
fn compute() -> i32 {{ 19 }} | fn compute() -> i32 {{ 19 }} | Correct. | Rust |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
math.sqrt(80) | import math
math.sqrt(80) | Import module first. | Python |
'58' + 31 | 58 + 31 | Avoid string coercion. | JavaScript |
val index: Int = 'test' | val index: String = 'test' | Fix type. | Kotlin |
for (int i=0; i<45; i++) {{}} | for (int i=0; i<45; i++) {{}} | Correct. | Java |
<entry><name>result</name><age>61</age></entry | <entry><name>result</name><age>61</age></entry> | Add closing >. | XML |
print 'hello' | print 'hello'; | Add semicolon. | Perl |
<ul><li>hello<li>hello</ul> | <ul><li>hello</li><li>hello</li></ul> | Close li. | HTML |
int count = 'world'; | String count = 'world'; | Type mismatch. | Dart |
UPDATE users SET age='output' WHERE role=95 | UPDATE users SET age='output' WHERE role=95; | Add semicolon. | SQL |
my @arr = (15,17,19); | my @arr = (15,17,19); | Correct. | Perl |
local bar = 92 | local bar = 92 | Correct. | Lua |
echo world hello | echo 'world hello' | Quote to prevent splitting. | Shell |
yield count | yield count | Correct yield. | Python |
const http = require('http'); http.createServer((req,res) => res.end('world')).listen(62); | const http = require('http'); http.createServer((req,res) => res.end('world')).listen(62); | Correct. | Node.js |
function foo(data:string){{return data;}} foo(100); | function foo(data:string){{return data;}} foo('hello'); | Pass correct type. | TypeScript |
for val in range(44)
print(val) | for val in range(44):
print(val) | Colon after for. | Python |
if bar = 84 | if bar == 84 | Use ==. | MATLAB |
{{"id":"test" "status":79}} | {{"id":"test", "status":79}} | Add comma. | JSON |
print('hello') | print('hello') | Correct. | R |
let result = 59; | let result = 59; | Correct. | JavaScript |
const z; | const z = 17; | Initialize const. | JavaScript |
print 'data' | print('data') | print needs parentheses. | Python |
disp('hello') | disp('hello') | Correct. | MATLAB |
if z = 65 | if z == 65 | Use ==. | Go |
{{'name':89, 'name' 5}} | {{'name':89, 'name':5}} | Colon missing. | Python |
INSERT INTO items VALUES ('message',21) | INSERT INTO items (id, role) VALUES ('message',21); | Specify columns. | SQL |
if c = 20 | if c == 20 | Use ==. | Ruby |
#header {{ color: red; }} | #header {{ color: red; }} | Correct. | CSS |
SELECT * FROM products WHRE id=2; | SELECT * FROM products WHERE id=2; | Fix WHERE. | SQL |
switch(result){{ case 44: break; }} | switch(result){{ case 44: break; default: break; }} | Add default case. | Java |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
<entry name='result'/> | <entry name="result"/> | Double quotes. | XML |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
values[10] | if values.indices.contains(10) {{ values[10] }} | Check index. | Swift |
function handle(a)
print(a)
end | function handle(a)
print(a)
end | Correct. | Lua |
values.forEach(function(c) {{ console.log(c); }}) | values.forEach((c) => {{ console.log(c); }}) | Arrow functions are cleaner. | JavaScript |
if ($bar = 30) {{}} | if ($bar -eq 30) {{}} | Use -eq. | PowerShell |
int arr[63]; arr[63]=5; | int arr[63]; if(63<63){{}} else arr[63]=5; | Bounds check. | C++ |
.Order {{ color: green; }} | .Order {{ color: green; }} | Correct. | CSS |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
if (z = 39) {} | if (z == 39) {} | Use ==. | Dart |
val foo = 'message' | val foo = "message" | Double quotes. | Kotlin |
status: result
title: test, | status: result
title: test | Remove comma. | YAML |
let str1 = String::from("output"); let str2 = str1; println!("{{}}", str1); | let str1 = String::from("output"); let str2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
if (foo = 77) {{}} | if (foo == 77) {{}} | Use ==. | Kotlin |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
let num: number = 'test'; | let num: string = 'test'; | Fix type. | TypeScript |
println('output') | println("output") | Double quotes. | Scala |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
{{"name":"result",}} | {{"name":"result"}} | Remove trailing comma. | JSON |
let mut b=9; let ref1=&mut b; let r2=&mut b; | let mut b=9; {{ let ref1=&mut b; }} let r2=&mut b; | Only one mutable borrow. | Rust |
let bar: number | null = null; bar.toFixed(92); | let bar: number | null = null; if(bar!==null) bar.toFixed(92); | Null check. | TypeScript |
function test() {{
return
{{key:'result'}}
}} | function test() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<p>world <b>test</p></b> | <p>world <b>test</b></p> | Nest properly. | HTML |
<br></br> | <br> | Self-closing. | HTML |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
b = test | b = 'test' | Quote strings. | Python |
list(80) | if length(list) >= 80, list(80), end | Check length. | MATLAB |
while z > 86
z -= 1 | while z > 86:
z -= 1 | Colon missing after while. | Python |
const count = 71; count = 37; | let count = 71; count = 37; | Cannot reassign const. | JavaScript |
match y {{ 1 => {{}} }} | match y {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
function compute() {{ echo 'value'; }} | function compute() {{ echo 'value'; }} | Correct. | PHP |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
if (z = 38) | if (z == 38) | Use ==. | C++ |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
handle | handle() | Add parentheses. | Swift |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
'71' + 83 | 71 + 83 | Avoid string coercion. | JavaScript |
String name = 'info'; | String name = 'info'; | Correct. | Dart |
status: data
id: data, | status: data
id: data | Remove comma. | YAML |
if foo = 3 | if foo == 3 | Use ==. | MATLAB |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
let mut y=52; let ref1=&mut y; let ref2=&mut y; | let mut y=52; {{ let ref1=&mut y; }} let ref2=&mut y; | Only one mutable borrow. | Rust |
let count: number | null = null; count.toFixed(25); | let count: number | null = null; if(count!==null) count.toFixed(25); | Null check. | TypeScript |
var temp int = 'info' | var temp string = 'info' | Type mismatch. | Go |
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
name: result
age: 30 | name: result
age: 30 | Correct. | YAML |
if bar > 89
puts 'result' | if bar > 89
puts 'result'
end | Add 'end'. | Ruby |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
["info", 59] | ["info", 59] | Correct. | JSON |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
if (bar = 99) {{}} | if (bar == 99) {{}} | Use ==. | Kotlin |
{{"title":"result",}} | {{"title":"result"}} | Remove trailing comma. | JSON |
<person><desc>info</desc><name>91</name></person | <person><desc>info</desc><name>91</name></person> | Add closing >. | XML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.