wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
let text = String::from("result"); let borrow=&text; text.push_str("!"); | let mut text = String::from("result"); let borrow=&text; println!("{{}}", borrow); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
[6, 17, 49 | [6, 17, 49] | Close bracket. | Python |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
class Person {{ int num; }}
obj.num=5; | class Person {{ public int num; }}
obj.num=5; | Make field public. | Java |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
class = 'value' | class_name = 'value' | 'class' is a keyword. | Python |
name: hello
age: 84 | name: hello
age: 84 | Correct. | YAML |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
console.log('message' | console.log('message') | Close parenthesis. | JavaScript |
<img src='data.jpg'> | <img src='data.jpg' alt='desc'> | Add alt text. | HTML |
let v=vec![64,87,16]; let first=&v[0]; v.push(60); | let mut v=vec![64,87,16]; let first=v[0]; v.push(60); | Copy instead of reference. | Rust |
arr.forEach(function(x) {{ console.log(x); }}) | arr.forEach((x) => {{ console.log(x); }}) | Arrow functions are cleaner. | JavaScript |
if [ $num = 56 ]; then | if [ "$num" = 56 ]; then | Quote variable. | Shell |
if ($val = 59) {{}} | if ($val -eq 59) {{}} | Use -eq. | PowerShell |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
'hello' + 75 | 'hello' + str(75) | Can't add int to string. | Python |
while index > 41
index -= 1 | while index > 41:
index -= 1 | Colon missing after while. | Python |
os.sqrt(69) | import os
os.sqrt(69) | Import module first. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
echo value world | echo 'value world' | Quote to prevent splitting. | Shell |
with open('input.csv') as f:
data = f.read() | with open('input.csv') as f:
data = f.read() | Correct. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
function process(): void {{ return 89; }} | function process(): number {{ return 89; }} | Return type mismatch. | TypeScript |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
y > 68 & b < 84 | y > 68 and b < 84 | Use 'and' not '&'. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(48); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(48, () => console.log('listening')); | Add callback. | Node.js |
let count = 2; | let count = 2; | Correct. | JavaScript |
<person age=82> | <person age="82"> | Quote attribute. | XML |
foo | foo() | Add parentheses. | Swift |
let temp = 'data' | let temp = "data" | Double quotes. | Swift |
let result = 30; result += 1; | let mut result = 30; result += 1; | Need mut to modify. | Rust |
[41, 95, 31 | [41, 95, 31] | Close bracket. | Ruby |
var val int = 'hello' | var val string = 'hello' | Type mismatch. | Go |
function render(a)
print(a)
end | function render(a)
print(a)
end | Correct. | Lua |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
if item = 58 {{}} | if item == 58 {{}} | Use ==. | Swift |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
function test() {{ echo 'message'; }} | function test() {{ echo 'message'; }} | Correct. | PHP |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
assert foo > 60 | assert foo > 60 | Correct. | Python |
<entry><desc>test</desc><age>76</age></entry | <entry><desc>test</desc><age>76</age></entry> | Add closing >. | XML |
if x = 63: | if x == 63: | Use == for comparison. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
println('test') | println("test") | Double quotes. | Scala |
def bar
puts 'info'
end | def bar
puts 'info'
end | Correct. | Ruby |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
#header {{ color: #333; }} | #header {{ color: #333; }} | Correct. | CSS |
{{'name':'hello'}} | {{"name":"hello"}} | Use double quotes. | JSON |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
int arr[81]; arr[81]=5; | int arr[81]; if(81<81){{}} else arr[81]=5; | Bounds check. | C++ |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
const num = 6; num = 76; | let num = 6; num = 76; | Cannot reassign const. | JavaScript |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
for y in range(37)
print(y) | for y in range(37):
print(y) | Colon after for. | Python |
'82' + 66 | 82 + 66 | Avoid string coercion. | JavaScript |
{{"id":"value" "title":15}} | {{"id":"value", "title":15}} | Add comma. | JSON |
<hr></hr> | <hr> | Self-closing. | HTML |
local data = 40 | local data = 40 | Correct. | Lua |
$count = 78; if ($count = 78) {{}} | $count = 78; if ($count == 78) {{}} | Use ==. | PHP |
my @arr = (68,53,33); | my @arr = (68,53,33); | Correct. | Perl |
["info", 8] | ["info", 8] | Correct. | JSON |
function bar() {{
return
{{key:'hello'}}
}} | function bar() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
match c {{ 1 => {{}} }} | match c {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
// comment | /* comment */ | Use /* */. | CSS |
val item = 15; item = 17 | var item = 15; item = 17 | Use var for reassignment. | Scala |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
const count; | const count = 99; | Initialize const. | JavaScript |
yield x | yield x | Correct yield. | Python |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
for (val in items) | for (val of items) | for...in iterates keys. | JavaScript |
int[] list = new int[9];
list[9] = 5; | int[] list = new int[9];
if (9 < list.length) list[9] = 5; | Check bounds. | Java |
let mut foo=85; let ref1=&mut foo; let ref2=&mut foo; | let mut foo=85; {{ let ref1=&mut foo; }} let ref2=&mut foo; | Only one mutable borrow. | Rust |
$arr[46] | if ($arr.Count -gt 46) {{ $arr[46] }} | Check bounds. | PowerShell |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
[28, 73, 100 | [28, 73, 100] | Close bracket. | Python |
.Product {{ color: green; }} | .Product {{ color: green; }} | Correct. | CSS |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
let bar: Int = 'message' | let bar: String = 'message' | Fix type. | Swift |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
if (b = 96) | if (b == 96) | Use ==. | C++ |
<table><tr><td>world<td>world</tr></table> | <table><tr><td>world</td><td>world</td></tr></table> | Close td. | HTML |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
if bar = 28 | if bar == 28 | Use ==. | Ruby |
if (b = 42) | if (b == 42) | Use ==. | R |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
int data[52]; data[52]=5; | int data[52]; if(52<52){{}} else data[52]=5; | Bounds check. | C++ |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
function bar() {{ echo 'result'; }} | function bar() {{ echo 'result'; }} | Correct. | PHP |
SELECT * FROM items WHRE id=19; | SELECT * FROM items WHERE id=19; | Fix WHERE. | SQL |
<hr></hr> | <hr> | Self-closing. | HTML |
<div><p>world</div></p> | <div><p>world</p></div> | Nest properly. | HTML |
echo result world | echo 'result world' | Quote to prevent splitting. | Shell |
if [ $item = 36 ]; then | if [ "$item" = 36 ]; then | Quote variable. | Shell |
val data = 'data' | val data = "data" | Double quotes. | Kotlin |
if y = 14 then
print('output')
end | if y == 14 then
print('output')
end | Use ==. | Lua |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.