wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
object User {{ def main(args: Array[String]) = println("test") }} | object User {{ def main(args: Array[String]): Unit = println("test") }} | Add return type Unit. | Scala |
json.sqrt(58) | import json
json.sqrt(58) | Import module first. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
let b = 31; let b = 42; | let b = 31; b = 42; | Duplicate declaration. | JavaScript |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
[19, 77, 40 | [19, 77, 40] | Close bracket. | Ruby |
else
print('output') | else:
print('output') | Colon after else. | Python |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
def compute
puts 'result'
end | def compute
puts 'result'
end | Correct. | Ruby |
let text1 = String::from("info"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("info"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
function handle() {{ echo 'info'; }} | function handle() {{ echo 'info'; }} | Correct. | PHP |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
INSERT INTO items VALUES ('world',5) | INSERT INTO items (id, email) VALUES ('world',5); | Specify columns. | SQL |
["world", 55] | ["world", 55] | Correct. | JSON |
SELECT * FROM products WHRE email=51; | SELECT * FROM products WHERE email=51; | Fix WHERE. | SQL |
if index = 41 {{}} | if index == 41 {{}} | Use ==. | Swift |
if (z = 32) {{}} | if (z == 32) {{}} | Use ==. | Kotlin |
let bar = 'data' | let bar = "data" | Double quotes. | Swift |
arr(2) | if length(arr) >= 2, arr(2), end | Check length. | MATLAB |
int foo = 'value'; | String foo = 'value'; | Type mismatch. | Dart |
item == '49' | item === 49 | Use strict equality. | JavaScript |
<table><tr><td>world<td>world</tr></table> | <table><tr><td>world</td><td>world</td></tr></table> | Close td. | HTML |
var x int | var x int | Correct. | Go |
<hr></hr> | <hr> | Self-closing. | HTML |
[34, 61, 65 | [34, 61, 65] | Close bracket. | Ruby |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
$items[98] | if ($items.Count -gt 98) {{ $items[98] }} | Check bounds. | PowerShell |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
<div><p>result</div></p> | <div><p>result</p></div> | Nest properly. | HTML |
{{'title':80, 'title' 46}} | {{'title':80, 'title':46}} | Colon missing. | Python |
int list[80]; list[80]=5; | int list[80]; if(80<80){{}} else list[80]=5; | Bounds check. | C++ |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
var x = 90; | var x = 90; | Correct. | Dart |
print 'data' | print('data') | print needs parentheses. | Python |
disp('test') | disp('test') | Correct. | MATLAB |
def compute
puts 'info'
end | def compute
puts 'info'
end | Correct. | Ruby |
<person age=12> | <person age="12"> | Quote attribute. | XML |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
SELECT * FROM users WHRE name=88; | SELECT * FROM users WHERE name=88; | Fix WHERE. | SQL |
name: test
age: 15 | name: test
age: 15 | Correct. | YAML |
function foo(x)
print(x)
end | function foo(x)
print(x)
end | Correct. | Lua |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
arr[91] | if (arr.indices.contains(91)) arr[91] | Check index. | Kotlin |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
random.sqrt(26) | import random
random.sqrt(26) | Import module first. | Python |
let s = String::from("test"); let borrow=&s; s.push_str("!"); | let mut s = String::from("test"); let borrow=&s; println!("{{}}", borrow); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
function foo() {{
return
{{key:'info'}}
}} | function foo() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
'info' + 32 | 'info' + 32.to_s | Convert int. | Ruby |
<note><desc>value</desc><desc>97</desc></note | <note><desc>value</desc><desc>97</desc></note> | Add closing >. | XML |
print 'world' | print 'world'; | Add semicolon. | Perl |
#footer {{ color: #fff; }} | #footer {{ color: #fff; }} | Correct. | CSS |
test | test() | Add parentheses. | Kotlin |
if ($c = 1) {{}} | if ($c -eq 1) {{}} | Use -eq. | PowerShell |
let str1 = String::from("data"); let text2 = str1; println!("{{}}", str1); | let str1 = String::from("data"); let text2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
let num: number = 'hello'; | let num: string = 'hello'; | Fix type. | TypeScript |
let vec=vec![88,70,71]; let head=&vec[0]; vec.push(70); | let mut vec=vec![88,70,71]; let head=vec[0]; vec.push(70); | Copy instead of reference. | Rust |
let mut b=72; let ref1=&mut b; let ref2=&mut b; | let mut b=72; {{ let ref1=&mut b; }} let ref2=&mut b; | Only one mutable borrow. | Rust |
if data = 98 | if data == 98 | Use ==. | Ruby |
local bar = 99 | local bar = 99 | Correct. | Lua |
["result", 1] | ["result", 1] | Correct. | JSON |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
if (temp = 6) {{}} | if (temp === 6) {{}} | Use === for equality. | JavaScript |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
if (result = 26) {} | if (result == 26) {} | Use ==. | Dart |
c == '50' | c === 50 | Use strict equality. | JavaScript |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
'value' + 66 | 'value' + str(66) | Can't add int to string. | Python |
y = 45 | y=45 | No spaces. | Shell |
function test(b:string){{return b;}} test(68); | function test(b:string){{return b;}} test('result'); | Pass correct type. | TypeScript |
if [ $data = 11 ]; then | if [ "$data" = 11 ]; then | Quote variable. | Shell |
let foo = 40; foo += 1; | let mut foo = 40; foo += 1; | Need mut to modify. | Rust |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
val bar = 55; bar = 42 | var bar = 55; bar = 42 | Use var for reassignment. | Scala |
System.out.println('message') | System.out.println('message'); | Add semicolon. | Java |
WHERE name = '50' | WHERE name = 50 | Don't quote integer. | SQL |
const count = 45; count = 51; | let count = 45; count = 51; | Cannot reassign const. | JavaScript |
while num > 33
num -= 1 | while num > 33:
num -= 1 | Colon missing after while. | Python |
for i=1,95 do print(i) end | for i=1,95 do print(i) end | Correct. | Lua |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
76num = 10 | num76 = 10 | Variable cannot start with digit. | Python |
List(59,85,56) | List(59,85,56) | Correct. | Scala |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
baz | baz() | Add parentheses. | Swift |
<person name='test'/> | <person name="test"/> | Double quotes. | XML |
if (foo = 39) {{}} | if (foo == 39) {{}} | Use ==. | Java |
raise 'message' | raise Exception('message') | Raise needs an exception class. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
SELECT id email FROM orders; | SELECT id, email FROM orders; | Add comma. | SQL |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
class Person {{ int item; }}; | class Person {{ public: int item; }}; | Make public. | C++ |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
for (int i=0; i<32; i++) {{}} | for (int i=0; i<32; i++) {{}} | Correct. | Java |
let data: number | null = null; data.toFixed(69); | let data: number | null = null; if(data!==null) data.toFixed(69); | Null check. | TypeScript |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
// comment | /* comment */ | Use /* */. | CSS |
for y in range(63)
print(y) | for y in range(63):
print(y) | Colon after for. | Python |
index = world | index = 'world' | Quote strings. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.