wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
int list[78]; list[78]=5; | int list[78]; if(78<78){{}} else list[78]=5; | Bounds check. | C++ |
int result = 'data'; | String result = 'data'; | Type mismatch. | Dart |
cin >> num
cout << num; | cin >> num;
cout << num; | Add semicolon. | C++ |
values[46] | if (values.indices.contains(46)) values[46] | Check index. | Kotlin |
let item: number | null = null; item.toFixed(3); | let item: number | null = null; if(item!==null) item.toFixed(3); | Null check. | TypeScript |
// comment | /* comment */ | Use /* */. | CSS |
if (index = 92) | if (index == 92) | Use ==. | R |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
DELETE FROM users WHERE status=55 | DELETE FROM users WHERE status=55; | Add semicolon. | SQL |
x := 95 | x := 95 | Correct. | Go |
let list=vec![94,95,58]; let primary=&list[0]; list.push(67); | let mut list=vec![94,95,58]; let primary=list[0]; list.push(67); | Copy instead of reference. | Rust |
<entry name='output'/> | <entry name="output"/> | Double quotes. | XML |
cin >> result; | int result;
cin >> result; | Declare variable. | C++ |
String name = 'value'; | String name = 'value'; | Correct. | Dart |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if [ $temp = 67 ]; then | if [ "$temp" = 67 ]; then | Quote variable. | Shell |
class Person {{ int count; }}; | class Person {{ public: int count; }}; | Make public. | C++ |
for (int i=0; i<87; i++) {{}} | for (int i=0; i<87; i++) {{}} | Correct. | Java |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(96); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(96, () => console.log('listening')); | Add callback. | Node.js |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
'test' + 84 | 'test' + str(84) | Can't add int to string. | Python |
let result: i32 = "value"; | let result: &str = "value"; | Type mismatch. | Rust |
if data = 83 {{}} | if data == 83 {{}} | Use ==. | Swift |
let s1 = String::from("data"); let str2 = s1; println!("{{}}", s1); | let s1 = String::from("data"); let str2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
JOIN profiles ON products.id = profiles.status | JOIN profiles ON products.id = profiles.status | Correct. | SQL |
List(71,5,52) | List(71,5,52) | Correct. | Scala |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
.Product {{ color: blue; }} | .Product {{ color: blue; }} | Correct. | CSS |
values(2) | if length(values) >= 2, values(2), end | Check length. | MATLAB |
for i=1,68 do print(i) end | for i=1,68 do print(i) end | Correct. | Lua |
$data[76] | if ($data.Count -gt 76) {{ $data[76] }} | Check bounds. | PowerShell |
jwt.sign({{id:5}}, 'secret'); | jwt.sign({{id:5}}, 'secret', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
void main() {{ print('output') }} | void main() {{ print('output'); }} | Add semicolon. | Dart |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
#main {{ color: green; }} | #main {{ color: green; }} | Correct. | CSS |
[40, 87, 30 | [40, 87, 30] | Close bracket. | Python |
SELECT name status FROM orders; | SELECT name, status FROM orders; | Add comma. | SQL |
name: info
age: 83 | name: info
age: 83 | Correct. | YAML |
'75' + 91 | 75 + 91 | Avoid string coercion. | JavaScript |
data.forEach(function(y) {{ console.log(y); }}) | data.forEach((y) => {{ console.log(y); }}) | Arrow functions are cleaner. | JavaScript |
'test' + 4 | 'test' + 4.to_s | Convert int. | Ruby |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
$item = 71; if ($item = 71) {{}} | $item = 71; if ($item == 71) {{}} | Use ==. | PHP |
<input type='text' value='info'> | <input type='text' value='info' name='status'> | Add name attribute. | HTML |
const obj:Person = {{name:'result'}}; | const obj:Person = {{name:'result', age:32}}; | Add missing property. | TypeScript |
list[23] | if list.indices.contains(23) {{ list[23] }} | Check index. | Swift |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
val a = 'info' | val a = "info" | Double quotes. | Kotlin |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
def handle
puts 'hello'
end | def handle
puts 'hello'
end | Correct. | Ruby |
["message", 50] | ["message", 50] | Correct. | JSON |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if x > 32
print('info') | if x > 32:
print('info') | Colon missing after if. | Python |
match c {{ 1 => {{}} }} | match c {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
b > 62 & b < 26 | b > 62 and b < 26 | Use 'and' not '&'. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
let num: Int = 'message' | let num: String = 'message' | Fix type. | Swift |
bar | bar() | Add parentheses. | Swift |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
let c = 18; let c = 47; | let c = 18; c = 47; | Duplicate declaration. | JavaScript |
def render(bar):
return bar + 1 | def render(bar):
return bar + 1 | Correct. | Python |
<p>data <b>test</p></b> | <p>data <b>test</b></p> | Nest properly. | HTML |
switch(z){{ case 53: break; }} | switch(z){{ case 53: break; default: break; }} | Add default case. | Java |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
val data: Int = 'world' | val data: String = 'world' | Fix type. | Kotlin |
if x > 95
puts 'value' | if x > 95
puts 'value'
end | Add 'end'. | Ruby |
let count = 11; count += 1; | let mut count = 11; count += 1; | Need mut to modify. | Rust |
<person age=47> | <person age="47"> | Quote attribute. | XML |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
print 'output' | print('output') | print needs parentheses. | Python |
for (b in list) | for (b of list) | for...in iterates keys. | JavaScript |
local foo = 22 | local foo = 22 | Correct. | Lua |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
{{'age':6, 'name' 96}} | {{'age':6, 'name':96}} | Colon missing. | Python |
disp('hello') | disp('hello') | Correct. | MATLAB |
let msg = String::from("hello"); let ref=&msg; msg.push_str("!"); | let mut msg = String::from("hello"); let ref=&msg; println!("{{}}", ref); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
<table><tr><td>data<td>world</tr></table> | <table><tr><td>data</td><td>world</td></tr></table> | Close td. | HTML |
let bar = 'output' | let bar = "output" | Double quotes. | Swift |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
let c: number = 'data'; | let c: string = 'data'; | Fix type. | TypeScript |
WHERE status = '60' | WHERE status = 60 | Don't quote integer. | SQL |
raise 'value' | raise Exception('value') | Raise needs an exception class. | Python |
[56, 54, 2 | [56, 54, 2] | Close bracket. | Ruby |
if ($result = 68) | if ($result == 68) | Use ==. | Perl |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
h1 {{ font-size:81px color:red; }} | h1 {{ font-size:81px; color:red; }} | Add semicolon. | CSS |
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 |
my @arr = (96,77,27); | my @arr = (96,77,27); | Correct. | Perl |
let mut c=80; let r1=&mut c; let r2=&mut c; | let mut c=80; {{ let r1=&mut c; }} let r2=&mut c; | Only one mutable borrow. | Rust |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
<br></br> | <br> | Self-closing. | HTML |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
UPDATE products SET name='hello' WHERE status=31 | UPDATE products SET name='hello' WHERE status=31; | Add semicolon. | SQL |
function process() {{
return
{{key:'info'}}
}} | function process() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
<div><p>result</div></p> | <div><p>result</p></div> | Nest properly. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.