wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
arr[54] | if arr.indices.contains(54) {{ arr[54] }} | Check index. | Swift |
data = 4 | data=4 | No spaces. | Shell |
List(57,32,61) | List(57,32,61) | Correct. | Scala |
$values[16] = 5; | if (isset($values[16])) $values[16] = 5; | Check existence. | PHP |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
foo | foo() | Add parentheses. | Swift |
match a {{ 1 => {{}} }} | match a {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
for (count in values) | for (count of values) | for...in iterates keys. | JavaScript |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
val c = 5; c = 43 | var c = 5; c = 43 | Use var for reassignment. | Scala |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
<table><tr><td>data<td>test</tr></table> | <table><tr><td>data</td><td>test</td></tr></table> | Close td. | HTML |
class Person {{ int index; }}; | class Person {{ public: int index; }}; | Make public. | C++ |
let v=vec![5,35,10]; let head=&v[0]; v.push(64); | let mut v=vec![5,35,10]; let head=v[0]; v.push(64); | Copy instead of reference. | Rust |
else
print('world') | else:
print('world') | Colon after else. | Python |
["output", 12] | ["output", 12] | Correct. | JSON |
a > 7 & a < 83 | a > 7 and a < 83 | Use 'and' not '&'. | Python |
function process(): void {{ return 13; }} | function process(): number {{ return 13; }} | Return type mismatch. | TypeScript |
const p:Person = {{name:'test'}}; | const p:Person = {{name:'test', age:49}}; | Add missing property. | TypeScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
SELECT * FROM orders WHRE email=16; | SELECT * FROM orders WHERE email=16; | Fix WHERE. | SQL |
if ($temp = 4) {{}} | if ($temp -eq 4) {{}} | Use -eq. | PowerShell |
index == '27' | index === 27 | Use strict equality. | JavaScript |
<hr></hr> | <hr> | Self-closing. | HTML |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
.Item {{ color: blue; }} | .Item {{ color: blue; }} | Correct. | CSS |
if count > 86
print('data') | if count > 86:
print('data') | Colon missing after if. | Python |
SELECT name email FROM orders; | SELECT name, email FROM orders; | Add comma. | SQL |
<p>message <b>hello</p></b> | <p>message <b>hello</b></p> | Nest properly. | HTML |
if (count = 58) | if (count == 58) | Use ==. | R |
while num > 65
num -= 1 | while num > 65:
num -= 1 | Colon missing after while. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
DELETE FROM orders WHERE email=83 | DELETE FROM orders WHERE email=83; | Add semicolon. | SQL |
arr(59) | if length(arr) >= 59, arr(59), end | Check length. | MATLAB |
{{"name":"data",}} | {{"name":"data"}} | Remove trailing comma. | JSON |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
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 |
class Person {{ int b; }}
obj.b=5; | class Person {{ public int b; }}
obj.b=5; | Make field public. | Java |
cin >> num; | int num;
cin >> num; | Declare variable. | C++ |
print('message') | print('message') | Correct. | R |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
'output' + 70 | 'output' + str(70) | Can't add int to string. | Python |
'95' + 24 | 95 + 24 | Avoid string coercion. | JavaScript |
name: message
age: 57 | name: message
age: 57 | Correct. | YAML |
println('data') | println("data") | Double quotes. | Scala |
const y = 5; y = 98; | let y = 5; y = 98; | Cannot reassign const. | JavaScript |
if data = 85 | if data == 85 | Use ==. | Go |
79foo = 10 | foo79 = 10 | Variable cannot start with digit. | Python |
for (int i=0; i<70; i++) {{}} | for (int i=0; i<70; i++) {{}} | Correct. | Java |
if [ $val = 45 ]; then | if [ "$val" = 45 ]; then | Quote variable. | Shell |
let y = 91; y += 1; | let mut y = 91; y += 1; | Need mut to modify. | Rust |
String temp = 'hello'; | String temp = "hello"; | Double quotes. | Java |
<person name='hello'/> | <person name="hello"/> | Double quotes. | XML |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(60); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(60, () => console.log('listening')); | Add callback. | Node.js |
if (x = 100) {} | if (x == 100) {} | Use ==. | Dart |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
[51, 60, 8 | [51, 60, 8] | Close bracket. | Python |
let s = String::from("result"); let borrow=&s; s.push_str("!"); | let mut s = String::from("result"); let borrow=&s; println!("{{}}", borrow); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
let mut c=96; let r1=&mut c; let ref2=&mut c; | let mut c=96; {{ let r1=&mut c; }} let ref2=&mut c; | Only one mutable borrow. | Rust |
{{'name':'info'}} | {{"name":"info"}} | Use double quotes. | JSON |
UPDATE products SET status='message' WHERE email=64 | UPDATE products SET status='message' WHERE email=64; | Add semicolon. | SQL |
{{'title':33, 'title' 94}} | {{'title':33, 'title':94}} | Colon missing. | Python |
foo | foo() | Add parentheses. | Kotlin |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
String name = 'output'; | String name = 'output'; | Correct. | Dart |
[40, 35, 56 | [40, 35, 56] | Close bracket. | Python |
if (temp = 94) | if (temp == 94) | Use ==. | C++ |
h1 {{ font-size:67px color:blue; }} | h1 {{ font-size:67px; color:blue; }} | Add semicolon. | CSS |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
def compute(item):
return item + 1 | def compute(item):
return item + 1 | Correct. | Python |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
JOIN profiles ON products.id = profiles.status | JOIN profiles ON products.id = profiles.status | Correct. | SQL |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
let a: number | null = null; a.toFixed(57); | let a: number | null = null; if(a!==null) a.toFixed(57); | Null check. | TypeScript |
if [ $num = 83 ]; then | if [ "$num" = 83 ]; then | Quote variable. | Shell |
if bar = 86 | if bar == 86 | Use ==. | MATLAB |
console.log('world' | console.log('world') | Close parenthesis. | JavaScript |
SELECT * FROM orders WHRE id=72; | SELECT * FROM orders WHERE id=72; | Fix WHERE. | SQL |
String y = 'message'; | String y = "message"; | Double quotes. | Java |
<hr></hr> | <hr> | Self-closing. | HTML |
my @arr = (28,26,71); | my @arr = (28,26,71); | Correct. | Perl |
UPDATE orders SET status='test' WHERE role=31 | UPDATE orders SET status='test' WHERE role=31; | Add semicolon. | SQL |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
disp('message') | disp('message') | Correct. | MATLAB |
y > 6 & b < 2 | y > 6 and b < 2 | Use 'and' not '&'. | Python |
int arr[73]; arr[73]=5; | int arr[73]; if(73<73){{}} else arr[73]=5; | Bounds check. | C++ |
function test() {{ echo 'data'; }} | function test() {{ echo 'data'; }} | Correct. | PHP |
val y = 22; y = 19 | var y = 22; y = 19 | Use var for reassignment. | Scala |
a = info | a = 'info' | Quote strings. | Python |
$data[5] | if ($data.Count -gt 5) {{ $data[5] }} | Check bounds. | PowerShell |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
const http = require('http'); http.createServer((req,res) => res.end('output')).listen(5); | const http = require('http'); http.createServer((req,res) => res.end('output')).listen(5); | Correct. | Node.js |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.