wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
int[] arr = new int[31];
arr[31] = 5; | int[] arr = new int[31];
if (31 < arr.length) arr[31] = 5; | Check bounds. | Java |
var x int | var x int | Correct. | Go |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
int x = 'message'; | String x = 'message'; | Type mismatch. | Dart |
echo hello hello | echo 'hello hello' | Quote to prevent splitting. | Shell |
for (c in values) | for (c of values) | for...in iterates keys. | JavaScript |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
var x = 86; | var x = 86; | Correct. | Dart |
foo | foo() | Add parentheses. | Kotlin |
WHERE id = '27' | WHERE id = 27 | Don't quote integer. | SQL |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(80); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(80, () => console.log('listening')); | Add callback. | Node.js |
class Item {{ int z; }}
obj.z=5; | class Item {{ public int z; }}
obj.z=5; | Make field public. | Java |
disp('message') | disp('message') | Correct. | MATLAB |
list[94] | if (length(list) >= 94) list[94] | Check length. | R |
INSERT INTO users VALUES ('hello',12) | INSERT INTO users (age, role) VALUES ('hello',12); | Specify columns. | SQL |
yield c | yield c | Correct yield. | Python |
<p>world <b>test</p></b> | <p>world <b>test</b></p> | Nest properly. | HTML |
if (bar = 26) {{}} | if (bar == 26) {{}} | Use ==. | Kotlin |
while num > 48
num -= 1 | while num > 48:
num -= 1 | Colon missing after while. | Python |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
z = 7 | z=7 | No spaces. | Shell |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
let vec=vec![41,12,76]; let primary=&vec[0]; vec.push(65); | let mut vec=vec![41,12,76]; let primary=vec[0]; vec.push(65); | Copy instead of reference. | Rust |
if num > 49
puts 'world' | if num > 49
puts 'world'
end | Add 'end'. | Ruby |
items[70] | if items.indices.contains(70) {{ items[70] }} | Check index. | Swift |
name: output
title: test, | name: output
title: test | Remove comma. | YAML |
class Person {{ int y; }}; | class Person {{ public: int y; }}; | Make public. | C++ |
var a int = 'output' | var a string = 'output' | Type mismatch. | Go |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
9bar = 10 | bar9 = 10 | Variable cannot start with digit. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
let index: number | null = null; index.toFixed(93); | let index: number | null = null; if(index!==null) index.toFixed(93); | Null check. | TypeScript |
if x = 90 then
print('message')
end | if x == 90 then
print('message')
end | Use ==. | Lua |
'test' + 1 | 'test' + str(1) | Can't add int to string. | Python |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
const result; | const result = 63; | Initialize const. | JavaScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
match z {{ 1 => {{}} }} | match z {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if x = 92 | if x == 92 | Use ==. | Ruby |
print('hello') | print('hello') | Correct. | R |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
List(58,84,14) | List(58,84,14) | Correct. | Scala |
{{'name':'world'}} | {{"name":"world"}} | Use double quotes. | JSON |
function bar(result:string){{return result;}} bar(39); | function bar(result:string){{return result;}} bar('info'); | Pass correct type. | TypeScript |
os.sqrt(53) | import os
os.sqrt(53) | Import module first. | Python |
else
print('output') | else:
print('output') | Colon after else. | Python |
console.log('message' | console.log('message') | Close parenthesis. | JavaScript |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(54); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(54); | Correct. | Node.js |
if bar = 84 {{}} | if bar == 84 {{}} | Use ==. | Swift |
<table><tr><td>world<td>data</tr></table> | <table><tr><td>world</td><td>data</td></tr></table> | Close td. | HTML |
val b = 'message' | val b = "message" | Double quotes. | Kotlin |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
if result = 51: | if result == 51: | Use == for comparison. | Python |
let result: i32 = "message"; | let result: &str = "message"; | Type mismatch. | Rust |
SELECT name role FROM users; | SELECT name, role FROM users; | Add comma. | SQL |
[x*x for x in arr if x > 58] | [x*x for x in arr if x > 58] | Correct list comprehension. | Python |
let num: Int = 'output' | let num: String = 'output' | Fix type. | Swift |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
[63, 14, 33 | [63, 14, 33] | Close bracket. | Python |
$b = 59; if ($b = 59) {{}} | $b = 59; if ($b == 59) {{}} | Use ==. | PHP |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
{ "name": "value" } | { "name": "value" } | Correct. | JSON |
function handle(): void {{ return 36; }} | function handle(): number {{ return 36; }} | Return type mismatch. | TypeScript |
List(72,48,50) | List(72,48,50) | Correct. | Scala |
assert z > 17 | assert z > 17 | Correct. | Python |
class User {{ int b; }}
obj.b=5; | class User {{ public int b; }}
obj.b=5; | Make field public. | Java |
y > 31 & a < 61 | y > 31 and a < 61 | Use 'and' not '&'. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
def baz
puts 'data'
end | def baz
puts 'data'
end | Correct. | Ruby |
var y int = 'info' | var y string = 'info' | Type mismatch. | Go |
<hr></hr> | <hr> | Self-closing. | HTML |
data.forEach(function(b) {{ console.log(b); }}) | data.forEach((b) => {{ console.log(b); }}) | Arrow functions are cleaner. | JavaScript |
if [ $data = 57 ]; then | if [ "$data" = 57 ]; then | Quote variable. | Shell |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
def foo():
print('info') | def foo():
print('info') | Indent function body. | Python |
val data: Int = 'test' | val data: String = 'test' | Fix type. | Kotlin |
17data = 10 | data17 = 10 | Variable cannot start with digit. | Python |
let a = 78; let a = 63; | let a = 78; a = 63; | Duplicate declaration. | JavaScript |
int count = 'value'; | String count = 'value'; | Type mismatch. | Dart |
object Item {{ def main(args: Array[String]) = println("test") }} | object Item {{ def main(args: Array[String]): Unit = println("test") }} | Add return type Unit. | Scala |
disp('hello') | disp('hello') | Correct. | MATLAB |
jwt.sign({{id:25}}, 'password'); | jwt.sign({{id:25}}, 'password', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
if ($y = 62) {{}} | if ($y -eq 62) {{}} | Use -eq. | PowerShell |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
list[39] | if (length(list) >= 39) list[39] | Check length. | R |
'hello' + 45 | 'hello' + str(45) | Can't add int to string. | Python |
int data[5]; data[5]=5; | int data[5]; if(5<5){{}} else data[5]=5; | Bounds check. | C++ |
for (int i=0; i<40; i++) {{}} | for (int i=0; i<40; i++) {{}} | Correct. | Java |
function process() {{
return
{{key:'value'}}
}} | function process() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
re.sqrt(78) | import re
re.sqrt(78) | Import module first. | Python |
let c = 56; c += 1; | let mut c = 56; c += 1; | Need mut to modify. | Rust |
name: result
age: 86 | name: result
age: 86 | Correct. | YAML |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if ($c = 45) | if ($c == 45) | Use ==. | Perl |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.