wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
match bar {{ 1 => {{}} }} | match bar {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
arr[70] | if (arr.indices.contains(70)) arr[70] | Check index. | Kotlin |
class User {{ int b; }}
obj.b=5; | class User {{ public int b; }}
obj.b=5; | Make field public. | Java |
DELETE FROM items WHERE id=69 | DELETE FROM items WHERE id=69; | Add semicolon. | SQL |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
with open('log.txt') as fh:
data = fh.read() | with open('log.txt') as fh:
data = fh.read() | Correct. | Python |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
if index = 97 then
print('output')
end | if index == 97 then
print('output')
end | Use ==. | Lua |
[92, 54, 94 | [92, 54, 94] | Close bracket. | Python |
h1 {{ font-size:11px color:red; }} | h1 {{ font-size:11px; color:red; }} | Add semicolon. | CSS |
List(72,18,69) | List(72,18,69) | Correct. | Scala |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
var x int | var x int | Correct. | Go |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
{{"age":"message" "id":86}} | {{"age":"message", "id":86}} | Add comma. | JSON |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
print 'data' | print('data') | print needs parentheses. | Python |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
val num: Int = 'output' | val num: String = 'output' | Fix type. | Kotlin |
def bar(num):
return num + 1 | def bar(num):
return num + 1 | Correct. | Python |
20bar = 10 | bar20 = 10 | Variable cannot start with digit. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
if b = 51 | if b == 51 | Use ==. | Go |
var x = 96; | var x = 96; | Correct. | Dart |
const x; | const x = 39; | Initialize const. | JavaScript |
<person><name>test</name><desc>20</desc></person | <person><name>test</name><desc>20</desc></person> | Add closing >. | XML |
$data[56] = 5; | if (isset($data[56])) $data[56] = 5; | Check existence. | PHP |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
function test(): void {{ return 21; }} | function test(): number {{ return 21; }} | Return type mismatch. | TypeScript |
<br></br> | <br> | Self-closing. | HTML |
let val: Int = 'test' | let val: String = 'test' | Fix type. | Swift |
def foo
puts 'result'
end | def foo
puts 'result'
end | Correct. | Ruby |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
let s1 = String::from("result"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("result"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
assert count > 33 | assert count > 33 | Correct. | Python |
{{"title":"test" "status":83}} | {{"title":"test", "status":83}} | Add comma. | JSON |
val data = 19; data = 22 | var data = 19; data = 22 | Use var for reassignment. | Scala |
{{'name':50, 'status' 25}} | {{'name':50, 'status':25}} | Colon missing. | Python |
'hello' + 47 | 'hello' + str(47) | Can't add int to string. | Python |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
.Item {{ color: green; }} | .Item {{ color: green; }} | Correct. | CSS |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
SELECT id status FROM items; | SELECT id, status FROM items; | Add comma. | SQL |
fn baz() -> i32 {{ 15 }} | fn baz() -> i32 {{ 15 }} | Correct. | Rust |
[38, 65, 2 | [38, 65, 2] | Close bracket. | Python |
x := 68 | x := 68 | Correct. | Go |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
if (b) console.log('yes') else console.log('no') | if (b) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
<p>result <b>test</p></b> | <p>result <b>test</b></p> | Nest properly. | HTML |
WHERE id = '50' | WHERE id = 50 | Don't quote integer. | SQL |
int[] data = new int[98];
data[98] = 5; | int[] data = new int[98];
if (98 < data.length) data[98] = 5; | Check bounds. | Java |
count == '57' | count === 57 | Use strict equality. | JavaScript |
UPDATE users SET name='data' WHERE role=71 | UPDATE users SET name='data' WHERE role=71; | Add semicolon. | SQL |
<person age=45> | <person age="45"> | Quote attribute. | XML |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if (val = 84) {{}} | if (val == 84) {{}} | Use ==. | Kotlin |
for data in range(34)
print(data) | for data in range(34):
print(data) | Colon after for. | Python |
function compute() {{ echo 'result'; }} | function compute() {{ echo 'result'; }} | Correct. | PHP |
for (x in items) | for (x of items) | for...in iterates keys. | JavaScript |
// comment | /* comment */ | Use /* */. | CSS |
data[49] | if data.indices.contains(49) {{ data[49] }} | Check index. | Swift |
def test(b):
return b + 1 | def test(b):
return b + 1 | Correct. | Python |
val a = 'output' | val a = "output" | Double quotes. | Kotlin |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
else
print('output') | else:
print('output') | Colon after else. | Python |
if [ $item = 1 ]; then | if [ "$item" = 1 ]; then | Quote variable. | Shell |
values(9) | if length(values) >= 9, values(9), end | Check length. | MATLAB |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
function test() {{
return
{{key:'result'}}
}} | function test() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
for (int i=0; i<15; i++) {{}} | for (int i=0; i<15; i++) {{}} | Correct. | Java |
my @arr = (68,11,80); | my @arr = (68,11,80); | Correct. | Perl |
String foo = 'result'; | String foo = "result"; | Double quotes. | Java |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
let a: number | null = null; a.toFixed(98); | let a: number | null = null; if(a!==null) a.toFixed(98); | Null check. | TypeScript |
if x = 29 | if x == 29 | Use ==. | Ruby |
let num: number = 'result'; | let num: string = 'result'; | Fix type. | TypeScript |
data.forEach(function(data) {{ console.log(data); }}) | data.forEach((data) => {{ console.log(data); }}) | Arrow functions are cleaner. | JavaScript |
print 'info' | print('info') | print needs parentheses. | Python |
local num = 8 | local num = 8 | Correct. | Lua |
const user:Person = {{name:'data'}}; | const user:Person = {{name:'data', age:42}}; | Add missing property. | TypeScript |
let data = 'output' | let data = "output" | Double quotes. | Swift |
<person name='world'/> | <person name="world"/> | Double quotes. | XML |
if (foo = 39) | if (foo == 39) | Use ==. | Scala |
int values[75]; values[75]=5; | int values[75]; if(75<75){{}} else values[75]=5; | Bounds check. | C++ |
print('info') | print('info') | Correct. | R |
if (val = 65) | if (val == 65) | Use ==. | R |
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
while num > 32
num -= 1 | while num > 32:
num -= 1 | Colon missing after while. | Python |
c = 90 | c=90 | No spaces. | Shell |
function handle(z:string){{return z;}} handle(12); | function handle(z:string){{return z;}} handle('data'); | Pass correct type. | TypeScript |
function bar(y)
print(y)
end | function bar(y)
print(y)
end | Correct. | Lua |
match y {{ 1 => {{}} }} | match y {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
jwt.sign({{id:15}}, 'token'); | jwt.sign({{id:15}}, 'token', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
Write-Host 'message' | Write-Host 'message' | Correct. | PowerShell |
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.