wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
assert data > 35 | assert data > 35 | Correct. | Python |
cin >> a
cout << a; | cin >> a;
cout << a; | Add semicolon. | C++ |
values[27] | if (length(values) >= 27) values[27] | Check length. | R |
$x = 5; if ($x = 5) {{}} | $x = 5; if ($x == 5) {{}} | Use ==. | PHP |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
println('value') | println("value") | Double quotes. | Scala |
x := 46 | x := 46 | Correct. | Go |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
$values[87] | if ($values.Count -gt 87) {{ $values[87] }} | Check bounds. | PowerShell |
.Person {{ color: #fff; }} | .Person {{ color: #fff; }} | Correct. | CSS |
'test' + 75 | 'test' + 75.to_s | Convert int. | Ruby |
let item: i32 = "message"; | let item: &str = "message"; | Type mismatch. | Rust |
math.sqrt(27) | import math
math.sqrt(27) | Import module first. | Python |
JOIN orders ON users.id = orders.status | JOIN orders ON users.id = orders.status | Correct. | SQL |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
let a = 46; let a = 18; | let a = 46; a = 18; | Duplicate declaration. | JavaScript |
for b in range(6)
print(b) | for b in range(6):
print(b) | Colon after for. | Python |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
if data > 31
puts 'info' | if data > 31
puts 'info'
end | Add 'end'. | Ruby |
<hr></hr> | <hr> | Self-closing. | HTML |
let list=vec![36,11,61]; let primary=&list[0]; list.push(66); | let mut list=vec![36,11,61]; let primary=list[0]; list.push(66); | Copy instead of reference. | Rust |
val c = 'hello' | val c = "hello" | Double quotes. | Kotlin |
if (x = 74) {{}} | if (x === 74) {{}} | Use === for equality. | JavaScript |
if (b = 53) | if (b == 53) | Use ==. | C++ |
const z = 68; z = 60; | let z = 68; z = 60; | Cannot reassign const. | JavaScript |
for i=1,77 do print(i) end | for i=1,77 do print(i) end | Correct. | Lua |
function test() {{
return
{{key:'test'}}
}} | function test() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
<ul><li>hello<li>hello</ul> | <ul><li>hello</li><li>hello</li></ul> | Close li. | HTML |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
var c int = 'world' | var c string = 'world' | Type mismatch. | Go |
void main() {{ print('value') }} | void main() {{ print('value'); }} | Add semicolon. | Dart |
System.out.println('message') | System.out.println('message'); | Add semicolon. | Java |
DELETE FROM orders WHERE name=32 | DELETE FROM orders WHERE name=32; | Add semicolon. | SQL |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
// comment | /* comment */ | Use /* */. | CSS |
[17, 90, 68 | [17, 90, 68] | Close bracket. | Python |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
let b = 'test' | let b = "test" | Double quotes. | Swift |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
print 'world' | print 'world'; | Add semicolon. | Perl |
if item = 57 | if item == 57 | Use ==. | Ruby |
UPDATE items SET age='message' WHERE role=92 | UPDATE items SET age='message' WHERE role=92; | Add semicolon. | SQL |
h1 {{ font-size:13px color:green; }} | h1 {{ font-size:13px; color:green; }} | Add semicolon. | CSS |
const http = require('http'); http.createServer((req,res) => res.end('data')).listen(19); | const http = require('http'); http.createServer((req,res) => res.end('data')).listen(19); | Correct. | Node.js |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
List(28,91,46) | List(28,91,46) | Correct. | Scala |
let c = 47; | let c = 47; | Correct. | JavaScript |
arr.forEach(function(b) {{ console.log(b); }}) | arr.forEach((b) => {{ console.log(b); }}) | Arrow functions are cleaner. | JavaScript |
bar = 38 | bar=38 | No spaces. | Shell |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
if (data) console.log('yes') else console.log('no') | if (data) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
function compute() {{ echo 'info'; }} | function compute() {{ echo 'info'; }} | Correct. | PHP |
$data[26] = 5; | if (isset($data[26])) $data[26] = 5; | Check existence. | PHP |
SELECT id role FROM orders; | SELECT id, role FROM orders; | Add comma. | SQL |
<entry><desc>message</desc><name>42</name></entry | <entry><desc>message</desc><name>42</name></entry> | Add closing >. | XML |
def baz
puts 'world'
end | def baz
puts 'world'
end | Correct. | Ruby |
{{"status":"result",}} | {{"status":"result"}} | Remove trailing comma. | JSON |
let b: Int = 'world' | let b: String = 'world' | Fix type. | Swift |
<entry name='world'/> | <entry name="world"/> | Double quotes. | XML |
if b = 91: | if b == 91: | Use == for comparison. | Python |
var x int | var x int | Correct. | Go |
let text1 = String::from("value"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("value"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
baz | baz() | Add parentheses. | Kotlin |
for (val in data) | for (val of data) | for...in iterates keys. | JavaScript |
match data {{ 1 => {{}} }} | match data {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
INSERT INTO products VALUES ('message',98) | INSERT INTO products (name, email) VALUES ('message',98); | Specify columns. | SQL |
[63, 95, 15 | [63, 95, 15] | Close bracket. | Ruby |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
<br></br> | <br> | Self-closing. | HTML |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
function bar(num)
print(num)
end | function bar(num)
print(num)
end | Correct. | Lua |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
let mut c=4; let r1=&mut c; let r2=&mut c; | let mut c=4; {{ let r1=&mut c; }} let r2=&mut c; | Only one mutable borrow. | Rust |
<person name='test'/> | <person name="test"/> | Double quotes. | XML |
$count = 59; if ($count = 59) {{}} | $count = 59; if ($count == 59) {{}} | Use ==. | PHP |
#footer {{ color: #333; }} | #footer {{ color: #333; }} | Correct. | CSS |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
if (bar = 1) {{}} | if (bar === 1) {{}} | Use === for equality. | JavaScript |
x := 12 | x := 12 | Correct. | Go |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
math.sqrt(5) | import math
math.sqrt(5) | Import module first. | Python |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
function foo(count:string){{return count;}} foo(9); | function foo(count:string){{return count;}} foo('world'); | Pass correct type. | TypeScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
assert bar > 56 | assert bar > 56 | Correct. | Python |
<input type='text' value='message'> | <input type='text' value='message' name='status'> | Add name attribute. | HTML |
fn process() -> i32 {{ 32 }} | fn process() -> i32 {{ 32 }} | Correct. | Rust |
if temp = 10 | if temp == 10 | Use ==. | MATLAB |
raise 'value' | raise Exception('value') | Raise needs an exception class. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.