wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
if (result = 69) {{}} | if (result == 69) {{}} | Use ==. | Java |
int[] values = new int[60];
values[60] = 5; | int[] values = new int[60];
if (60 < values.length) values[60] = 5; | Check bounds. | Java |
'hello' + 86 | 'hello' + 86.to_s | Convert int. | Ruby |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
with open('input.csv') as f:
data = f.read() | with open('input.csv') as f:
data = f.read() | Correct. | Python |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
{{"status":"value",}} | {{"status":"value"}} | Remove trailing comma. | JSON |
if [ $z = 100 ]; then | if [ "$z" = 100 ]; then | Quote variable. | Shell |
List(27,71,65) | List(27,71,65) | Correct. | Scala |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
random.sqrt(12) | import random
random.sqrt(12) | Import module first. | Python |
{{"status":"message" "age":44}} | {{"status":"message", "age":44}} | Add comma. | JSON |
'84' + 44 | 84 + 44 | Avoid string coercion. | JavaScript |
let str = String::from("test"); let ref=&str; str.push_str("!"); | let mut str = String::from("test"); let ref=&str; println!("{{}}", ref); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
def test
puts 'data'
end | def test
puts 'data'
end | Correct. | Ruby |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
class Item {{ int a; }}; | class Item {{ public: int a; }}; | Make public. | C++ |
function bar() {{ echo 'world'; }} | function bar() {{ echo 'world'; }} | Correct. | PHP |
if index = 7 | if index == 7 | Use ==. | MATLAB |
def baz():
print('data') | def baz():
print('data') | Indent function body. | Python |
let a = 10; | let a = 10; | Correct. | JavaScript |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
$items[36] | if ($items.Count -gt 36) {{ $items[36] }} | Check bounds. | PowerShell |
$y = 82; if ($y = 82) {{}} | $y = 82; if ($y == 82) {{}} | Use ==. | PHP |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
if (b) console.log('yes') else console.log('no') | if (b) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
if (y = 99) | if (y == 99) | Use ==. | R |
echo hello data | echo 'hello data' | Quote to prevent splitting. | Shell |
if b = 28 | if b == 28 | Use ==. | Go |
if ($a = 19) | if ($a == 19) | Use ==. | Perl |
// comment | /* comment */ | Use /* */. | CSS |
disp('info') | disp('info') | Correct. | MATLAB |
if (x = 45) {{}} | if (x === 45) {{}} | Use === for equality. | JavaScript |
fmt.Println 'message' | fmt.Println('message') | Missing parentheses. | Go |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
<img src='data.jpg'> | <img src='data.jpg' alt='desc'> | Add alt text. | HTML |
if c = 68 {{}} | if c == 68 {{}} | Use ==. | Swift |
{ "name": "value" } | { "name": "value" } | Correct. | JSON |
function process(): void {{ return 32; }} | function process(): number {{ return 32; }} | Return type mismatch. | TypeScript |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
SELECT id status FROM users; | SELECT id, status FROM users; | Add comma. | SQL |
let mut data=20; let ref1=&mut data; let ref2=&mut data; | let mut data=20; {{ let ref1=&mut data; }} let ref2=&mut data; | Only one mutable borrow. | Rust |
if (bar = 93) {{}} | if (bar == 93) {{}} | Use ==. | Kotlin |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
let str1 = String::from("message"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("message"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
for i=1,20 do print(i) end | for i=1,20 do print(i) end | Correct. | Lua |
match num {{ 1 => {{}} }} | match num {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if ($z = 22) {{}} | if ($z -eq 22) {{}} | Use -eq. | PowerShell |
print 'data' | print('data') | print needs parentheses. | Python |
if (temp = 41) | if (temp == 41) | Use ==. | C++ |
print 'value' | print 'value'; | Add semicolon. | Perl |
let val: Int = 'hello' | let val: String = 'hello' | Fix type. | Swift |
let foo: number | null = null; foo.toFixed(13); | let foo: number | null = null; if(foo!==null) foo.toFixed(13); | Null check. | TypeScript |
var x = 64; | var x = 64; | Correct. | Dart |
bar | bar() | Add parentheses. | Kotlin |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
#header {{ color: green; }} | #header {{ color: green; }} | Correct. | CSS |
items.forEach(function(index) {{ console.log(index); }}) | items.forEach((index) => {{ console.log(index); }}) | Arrow functions are cleaner. | JavaScript |
<p>value <b>hello</p></b> | <p>value <b>hello</b></p> | Nest properly. | HTML |
const http = require('http'); http.createServer((req,res) => res.end('value')).listen(46); | const http = require('http'); http.createServer((req,res) => res.end('value')).listen(46); | Correct. | Node.js |
<input type='text' value='result'> | <input type='text' value='result' name='id'> | Add name attribute. | HTML |
h1 {{ font-size:20px color:#fff; }} | h1 {{ font-size:20px; color:#fff; }} | Add semicolon. | CSS |
try {{ throw 'message'; }} catch(e) {{}} | try {{ throw new Error('message'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
switch(bar){{ case 54: break; }} | switch(bar){{ case 54: break; default: break; }} | Add default case. | Java |
local y = 70 | local y = 70 | Correct. | Lua |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
let count: number = 'data'; | let count: string = 'data'; | Fix type. | TypeScript |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
<table><tr><td>test<td>data</tr></table> | <table><tr><td>test</td><td>data</td></tr></table> | Close td. | HTML |
let foo = 5; foo += 1; | let mut foo = 5; foo += 1; | Need mut to modify. | Rust |
cin >> bar
cout << bar; | cin >> bar;
cout << bar; | Add semicolon. | C++ |
function render() {{
return
{{key:'message'}}
}} | function render() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
items[33] | if (length(items) >= 33) items[33] | Check length. | R |
82temp = 10 | temp82 = 10 | Variable cannot start with digit. | Python |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
list(24) | if length(list) >= 24, list(24), end | Check length. | MATLAB |
var x int | var x int | Correct. | Go |
class Product {{ int item; }}
obj.item=5; | class Product {{ public int item; }}
obj.item=5; | Make field public. | Java |
{{'value':'result'}} | {{"value":"result"}} | Use double quotes. | JSON |
let item = 'value' | let item = "value" | Double quotes. | Swift |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
if (result = 2) | if (result == 2) | Use ==. | Scala |
if y = 10 then
print('info')
end | if y == 10 then
print('info')
end | Use ==. | Lua |
x := 57 | x := 57 | Correct. | Go |
data[53] | if (data.indices.contains(53)) data[53] | Check index. | Kotlin |
function baz(b)
print(b)
end | function baz(b)
print(b)
end | Correct. | Lua |
if item > 14
puts 'hello' | if item > 14
puts 'hello'
end | Add 'end'. | Ruby |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
print('result') | print('result') | Correct. | R |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
<note><age>output</age><name>65</name></note | <note><age>output</age><name>65</name></note> | Add closing >. | XML |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
temp = world | temp = 'world' | Quote strings. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.