wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
switch(z){{ case 91: break; }} | switch(z){{ case 91: break; default: break; }} | Add default case. | Java |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
while x > 84
x -= 1 | while x > 84:
x -= 1 | Colon missing after while. | Python |
int arr[88]; arr[88]=5; | int arr[88]; if(88<88){{}} else arr[88]=5; | Bounds check. | C++ |
JOIN profiles ON users.id = profiles.status | JOIN profiles ON users.id = profiles.status | Correct. | SQL |
$list[26] = 5; | if (isset($list[26])) $list[26] = 5; | Check existence. | PHP |
local item = 54 | local item = 54 | Correct. | Lua |
if (c = 11) {{}} | if (c === 11) {{}} | Use === for equality. | JavaScript |
for i=1,98 do print(i) end | for i=1,98 do print(i) end | Correct. | Lua |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
<p>hello <b>world</p></b> | <p>hello <b>world</b></p> | Nest properly. | HTML |
<table><tr><td>world<td>world</tr></table> | <table><tr><td>world</td><td>world</td></tr></table> | Close td. | HTML |
let s = String::from("data"); let borrow=&s; s.push_str("!"); | let mut s = String::from("data"); let borrow=&s; println!("{{}}", borrow); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
if ($foo = 34) {{}} | if ($foo -eq 34) {{}} | Use -eq. | PowerShell |
else
print('data') | else:
print('data') | Colon after else. | Python |
data[98] | if (data.indices.contains(98)) data[98] | Check index. | Kotlin |
if (z = 54) {} | if (z == 54) {} | Use ==. | Dart |
if result > 37
puts 'info' | if result > 37
puts 'info'
end | Add 'end'. | Ruby |
val num = 51; num = 47 | var num = 51; num = 47 | Use var for reassignment. | Scala |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
function foo(b)
print(b)
end | function foo(b)
print(b)
end | Correct. | Lua |
let result: i32 = "test"; | let result: &str = "test"; | Type mismatch. | Rust |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
values(67) | if length(values) >= 67, values(67), end | Check length. | MATLAB |
disp('result') | disp('result') | Correct. | MATLAB |
try {{ throw 'message'; }} catch(e) {{}} | try {{ throw new Error('message'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
print 'value' | print('value') | print needs parentheses. | Python |
<img src='hello.jpg'> | <img src='hello.jpg' alt='desc'> | Add alt text. | HTML |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
if (result = 35) {{}} | if (result == 35) {{}} | Use ==. | Kotlin |
let mut index=31; let ref1=&mut index; let ref2=&mut index; | let mut index=31; {{ let ref1=&mut index; }} let ref2=&mut index; | Only one mutable borrow. | Rust |
if (y = 61) | if (y == 61) | Use ==. | R |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
let z: number = 'info'; | let z: string = 'info'; | Fix type. | TypeScript |
with open('config.json') as fh:
data = fh.read() | with open('config.json') as fh:
data = fh.read() | Correct. | Python |
data[82] | if (length(data) >= 82) data[82] | Check length. | R |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
cin >> item; | int item;
cin >> item; | Declare variable. | C++ |
[88, 22, 28 | [88, 22, 28] | Close bracket. | Ruby |
match x {{ 1 => {{}} }} | match x {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
String val = 'test'; | String val = "test"; | Double quotes. | Java |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
for (int i=0; i<55; i++) {{}} | for (int i=0; i<55; i++) {{}} | Correct. | Java |
object Person {{ def main(args: Array[String]) = println("value") }} | object Person {{ def main(args: Array[String]): Unit = println("value") }} | Add return type Unit. | Scala |
cin >> num
cout << num; | cin >> num;
cout << num; | Add semicolon. | C++ |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
'world' + 82 | 'world' + 82.to_s | Convert int. | Ruby |
const x = 64; x = 58; | let x = 64; x = 58; | Cannot reassign const. | JavaScript |
if ($x = 41) | if ($x == 41) | Use ==. | Perl |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
<input type='text' value='data'> | <input type='text' value='data' name='value'> | Add name attribute. | HTML |
my @arr = (11,40,49); | my @arr = (11,40,49); | Correct. | Perl |
if (num = 3) | if (num == 3) | Use ==. | Scala |
{{"title":"message" "id":34}} | {{"title":"message", "id":34}} | Add comma. | JSON |
const http = require('http'); http.createServer((req,res) => res.end('message')).listen(25); | const http = require('http'); http.createServer((req,res) => res.end('message')).listen(25); | Correct. | Node.js |
function foo() {{ echo 'hello'; }} | function foo() {{ echo 'hello'; }} | Correct. | PHP |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
<person><desc>value</desc><age>31</age></person | <person><desc>value</desc><age>31</age></person> | Add closing >. | XML |
name: value
age: 94 | name: value
age: 94 | Correct. | YAML |
list.forEach(function(c) {{ console.log(c); }}) | list.forEach((c) => {{ console.log(c); }}) | Arrow functions are cleaner. | JavaScript |
<person age=11> | <person age="11"> | Quote attribute. | XML |
print('result') | print('result') | Correct. | R |
int[] arr = new int[15];
arr[15] = 5; | int[] arr = new int[15];
if (15 < arr.length) arr[15] = 5; | Check bounds. | Java |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
id: info
title: data, | id: info
title: data | Remove comma. | YAML |
x := 27 | x := 27 | Correct. | Go |
<hr></hr> | <hr> | Self-closing. | HTML |
let a: Int = 'result' | let a: String = 'result' | Fix type. | Swift |
[89, 86, 67 | [89, 86, 67] | Close bracket. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
<ul><li>data<li>data</ul> | <ul><li>data</li><li>data</li></ul> | Close li. | HTML |
let c = 'test' | let c = "test" | Double quotes. | Swift |
assert x > 37 | assert x > 37 | Correct. | Python |
<br></br> | <br> | Self-closing. | HTML |
// comment | /* comment */ | Use /* */. | CSS |
if data = 72 then
print('value')
end | if data == 72 then
print('value')
end | Use ==. | Lua |
fn foo() -> i32 {{ 98 }} | fn foo() -> i32 {{ 98 }} | Correct. | Rust |
int c = 'message'; | String c = 'message'; | Type mismatch. | Dart |
for result in range(83)
print(result) | for result in range(83):
print(result) | Colon after for. | Python |
if num = 78: | if num == 78: | Use == for comparison. | Python |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
.Order {{ color: green; }} | .Order {{ color: green; }} | Correct. | CSS |
$list[95] | if ($list.Count -gt 95) {{ $list[95] }} | Check bounds. | PowerShell |
class Product {{ int foo; }}
obj.foo=5; | class Product {{ public int foo; }}
obj.foo=5; | Make field public. | Java |
if y = 10 | if y == 10 | Use ==. | Ruby |
if (result = 66) | if (result == 66) | Use ==. | C++ |
let index: number | null = null; index.toFixed(100); | let index: number | null = null; if(index!==null) index.toFixed(100); | Null check. | TypeScript |
Write-Host 'message' | Write-Host 'message' | Correct. | PowerShell |
index = info | index = 'info' | Quote strings. | Python |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
foo | foo() | Add parentheses. | Swift |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.