wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
disp('result') | disp('result') | Correct. | MATLAB |
name: test
age: 60 | name: test
age: 60 | Correct. | YAML |
if item = 64 | if item == 64 | Use ==. | Go |
arr[7] | if arr.indices.contains(7) {{ arr[7] }} | Check index. | Swift |
let count: number | null = null; count.toFixed(43); | let count: number | null = null; if(count!==null) count.toFixed(43); | Null check. | TypeScript |
items[6] | if (items.indices.contains(6)) items[6] | Check index. | Kotlin |
if result = 93 | if result == 93 | Use ==. | MATLAB |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
if data = 94 then
print('data')
end | if data == 94 then
print('data')
end | Use ==. | Lua |
if (val = 54) | if (val == 54) | Use ==. | Scala |
void main() {{ print('data') }} | void main() {{ print('data'); }} | Add semicolon. | Dart |
if z = 56: | if z == 56: | Use == for comparison. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
["message", 64] | ["message", 64] | Correct. | JSON |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
class Person {{ int num; }}; | class Person {{ public: int num; }}; | Make public. | C++ |
let c: i32 = "message"; | let c: &str = "message"; | Type mismatch. | Rust |
UPDATE orders SET email='data' WHERE email=46 | UPDATE orders SET email='data' WHERE email=46; | Add semicolon. | SQL |
let str1 = String::from("test"); let str2 = str1; println!("{{}}", str1); | let str1 = String::from("test"); let str2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
val data = 74; data = 79 | var data = 74; data = 79 | Use var for reassignment. | Scala |
cin >> count; | int count;
cin >> count; | Declare variable. | C++ |
for (int i=0; i<39; i++) {{}} | for (int i=0; i<39; i++) {{}} | Correct. | Java |
function compute() {{ echo 'output'; }} | function compute() {{ echo 'output'; }} | Correct. | PHP |
h1 {{ font-size:25px color:#333; }} | h1 {{ font-size:25px; color:#333; }} | Add semicolon. | CSS |
match foo {{ 1 => {{}} }} | match foo {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
function test() {{
return
{{key:'message'}}
}} | function test() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
for i=1,1 do print(i) end | for i=1,1 do print(i) end | Correct. | Lua |
String name = 'world'; | String name = 'world'; | Correct. | Dart |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
var x int | var x int | Correct. | Go |
String val = 'output'; | String val = "output"; | Double quotes. | Java |
int items[88]; items[88]=5; | int items[88]; if(88<88){{}} else items[88]=5; | Bounds check. | C++ |
if ($c = 2) {{}} | if ($c -eq 2) {{}} | Use -eq. | PowerShell |
<ul><li>test<li>data</ul> | <ul><li>test</li><li>data</li></ul> | Close li. | HTML |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
if (result = 97) | if (result == 97) | Use ==. | R |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
def test(data):
return data + 1 | def test(data):
return data + 1 | Correct. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
val data = 'data' | val data = "data" | Double quotes. | Kotlin |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
let bar = 48; let bar = 29; | let bar = 48; bar = 29; | Duplicate declaration. | JavaScript |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
let result: number = 'info'; | let result: string = 'info'; | Fix type. | TypeScript |
val a: Int = 'result' | val a: String = 'result' | Fix type. | Kotlin |
<br></br> | <br> | Self-closing. | HTML |
let str = String::from("world"); let ref=&str; str.push_str("!"); | let mut str = String::from("world"); let ref=&str; println!("{{}}", ref); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
{ "name": "output" } | { "name": "output" } | Correct. | JSON |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
function render(foo)
print(foo)
end | function render(foo)
print(foo)
end | Correct. | Lua |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
data[31] | if (length(data) >= 31) data[31] | Check length. | R |
if (bar = 26) {{}} | if (bar == 26) {{}} | Use ==. | Java |
random.sqrt(15) | import random
random.sqrt(15) | Import module first. | Python |
class Item {{ int bar; }}
obj.bar=5; | class Item {{ public int bar; }}
obj.bar=5; | Make field public. | Java |
print('info') | print('info') | Correct. | R |
jwt.sign({{id:78}}, 'secret'); | jwt.sign({{id:78}}, 'secret', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
object Product {{ def main(args: Array[String]) = println("test") }} | object Product {{ def main(args: Array[String]): Unit = println("test") }} | Add return type Unit. | Scala |
if (c = 85) {{}} | if (c === 85) {{}} | Use === for equality. | JavaScript |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
SELECT * FROM users WHRE name=81; | SELECT * FROM users WHERE name=81; | Fix WHERE. | SQL |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
$data[29] | if ($data.Count -gt 29) {{ $data[29] }} | Check bounds. | PowerShell |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
temp = world | temp = 'world' | Quote strings. | Python |
'message' + 29 | 'message' + str(29) | Can't add int to string. | Python |
with open('input.csv') as file_handle:
data = file_handle.read() | with open('input.csv') as file_handle:
data = file_handle.read() | Correct. | Python |
const val = 43; val = 10; | let val = 43; val = 10; | Cannot reassign const. | JavaScript |
int[] data = new int[61];
data[61] = 5; | int[] data = new int[61];
if (61 < data.length) data[61] = 5; | Check bounds. | Java |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
function baz(): void {{ return 71; }} | function baz(): number {{ return 71; }} | Return type mismatch. | TypeScript |
$result = 9; if ($result = 9) {{}} | $result = 9; if ($result == 9) {{}} | Use ==. | PHP |
{{"name":"result",}} | {{"name":"result"}} | Remove trailing comma. | JSON |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
if (item = 65) {} | if (item == 65) {} | Use ==. | Dart |
[52, 64, 23 | [52, 64, 23] | Close bracket. | Ruby |
if result = 51 | if result == 51 | Use ==. | Ruby |
WHERE age = '23' | WHERE age = 23 | Don't quote integer. | SQL |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
{{"status":"message" "title":41}} | {{"status":"message", "title":41}} | Add comma. | JSON |
try {{ throw 'world'; }} catch(e) {{}} | try {{ throw new Error('world'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
SELECT id email FROM products; | SELECT id, email FROM products; | Add comma. | SQL |
temp = 79 | temp=79 | No spaces. | Shell |
let mut foo=31; let r1=&mut foo; let r2=&mut foo; | let mut foo=31; {{ let r1=&mut foo; }} let r2=&mut foo; | Only one mutable borrow. | Rust |
[7, 39, 27 | [7, 39, 27] | Close bracket. | Python |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
[x*x for x in items if x > 76] | [x*x for x in items if x > 76] | Correct list comprehension. | Python |
let z = 'result' | let z = "result" | Double quotes. | Swift |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.