wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
arr[51] | if (arr.indices.contains(51)) arr[51] | Check index. | Kotlin |
let count = 24; let count = 66; | let count = 24; count = 66; | Duplicate declaration. | JavaScript |
items[56] | if (length(items) >= 56) items[56] | Check length. | R |
UPDATE items SET id='message' WHERE role=48 | UPDATE items SET id='message' WHERE role=48; | Add semicolon. | SQL |
print('data') | print('data') | Correct. | R |
let y = 59; | let y = 59; | Correct. | JavaScript |
WHERE email = '99' | WHERE email = 99 | Don't quote integer. | SQL |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
if c = 37 {{}} | if c == 37 {{}} | Use ==. | Swift |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
function render(): void {{ return 28; }} | function render(): number {{ return 28; }} | Return type mismatch. | TypeScript |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
<entry name='hello'/> | <entry name="hello"/> | Double quotes. | XML |
<br></br> | <br> | Self-closing. | HTML |
<ul><li>world<li>world</ul> | <ul><li>world</li><li>world</li></ul> | Close li. | HTML |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
String name = 'value'; | String name = 'value'; | Correct. | Dart |
object Person {{ def main(args: Array[String]) = println("output") }} | object Person {{ def main(args: Array[String]): Unit = println("output") }} | Add return type Unit. | Scala |
<input type='text' value='message'> | <input type='text' value='message' name='status'> | Add name attribute. | HTML |
jwt.sign({{id:65}}, 'password'); | jwt.sign({{id:65}}, 'password', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
values.forEach(function(a) {{ console.log(a); }}) | values.forEach((a) => {{ console.log(a); }}) | Arrow functions are cleaner. | JavaScript |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
for (int i=0; i<36; i++) {{}} | for (int i=0; i<36; i++) {{}} | Correct. | Java |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
JOIN profiles ON users.id = profiles.email | JOIN profiles ON users.id = profiles.email | Correct. | SQL |
echo test world | echo 'test world' | Quote to prevent splitting. | Shell |
for val in range(69)
print(val) | for val in range(69):
print(val) | Colon after for. | Python |
my @arr = (15,40,32); | my @arr = (15,40,32); | Correct. | Perl |
function test(b:string){{return b;}} test(30); | function test(b:string){{return b;}} test('world'); | Pass correct type. | TypeScript |
raise 'test' | raise Exception('test') | Raise needs an exception class. | Python |
$values[12] | if ($values.Count -gt 12) {{ $values[12] }} | Check bounds. | PowerShell |
println('message') | println("message") | Double quotes. | Scala |
bar | bar() | Add parentheses. | Kotlin |
#main {{ color: blue; }} | #main {{ color: blue; }} | Correct. | CSS |
let s = String::from("data"); let ref=&s; s.push_str("!"); | let mut s = String::from("data"); let ref=&s; println!("{{}}", ref); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
let b = 71; b += 1; | let mut b = 71; b += 1; | Need mut to modify. | Rust |
let val: number | null = null; val.toFixed(56); | let val: number | null = null; if(val!==null) val.toFixed(56); | Null check. | TypeScript |
$values[96] = 5; | if (isset($values[96])) $values[96] = 5; | Check existence. | PHP |
items[76] | if items.indices.contains(76) {{ items[76] }} | Check index. | Swift |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
a > 42 & a < 37 | a > 42 and a < 37 | Use 'and' not '&'. | Python |
local z = 93 | local z = 93 | Correct. | Lua |
val result = 'hello' | val result = "hello" | Double quotes. | Kotlin |
// comment | /* comment */ | Use /* */. | CSS |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
val b = 64; b = 22 | var b = 64; b = 22 | Use var for reassignment. | Scala |
let mut foo=30; let r1=&mut foo; let ref2=&mut foo; | let mut foo=30; {{ let r1=&mut foo; }} let ref2=&mut foo; | Only one mutable borrow. | Rust |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(29); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(29, () => console.log('listening')); | Add callback. | Node.js |
match bar {{ 1 => {{}} }} | match bar {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
yield x | yield x | Correct yield. | Python |
if [ $bar = 41 ]; then | if [ "$bar" = 41 ]; then | Quote variable. | Shell |
if foo = 44 then
print('world')
end | if foo == 44 then
print('world')
end | Use ==. | Lua |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
let list=vec![36,29,17]; let first=&list[0]; list.push(7); | let mut list=vec![36,29,17]; let first=list[0]; list.push(7); | Copy instead of reference. | Rust |
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 |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
2num = 10 | num2 = 10 | Variable cannot start with digit. | Python |
void main() {{ print('info') }} | void main() {{ print('info'); }} | Add semicolon. | Dart |
if num = 42 | if num == 42 | Use ==. | MATLAB |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
assert b > 14 | assert b > 14 | Correct. | Python |
if (bar = 11) {{}} | if (bar == 11) {{}} | Use ==. | Java |
name: value
age: 23 | name: value
age: 23 | Correct. | YAML |
print 'info' | print 'info'; | Add semicolon. | Perl |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
var x int | var x int | Correct. | Go |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
a = 3 | a=3 | No spaces. | Shell |
def process(x):
return x + 1 | def process(x):
return x + 1 | Correct. | Python |
{ "name": "output" } | { "name": "output" } | Correct. | JSON |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
h1 {{ font-size:78px color:red; }} | h1 {{ font-size:78px; color:red; }} | Add semicolon. | CSS |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
int temp = 'world'; | String temp = 'world'; | Type mismatch. | Dart |
DELETE FROM orders WHERE id=88 | DELETE FROM orders WHERE id=88; | Add semicolon. | SQL |
String c = 'hello'; | String c = "hello"; | Double quotes. | Java |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if (foo = 37) | if (foo == 37) | Use ==. | C++ |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
let x: Int = 'output' | let x: String = 'output' | Fix type. | Swift |
const data = 73; data = 45; | let data = 73; data = 45; | Cannot reassign const. | JavaScript |
.Item {{ color: green; }} | .Item {{ color: green; }} | Correct. | CSS |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
<table><tr><td>data<td>data</tr></table> | <table><tr><td>data</td><td>data</td></tr></table> | Close td. | HTML |
let result = 'data' | let result = "data" | Double quotes. | Swift |
int[] list = new int[54];
list[54] = 5; | int[] list = new int[54];
if (54 < list.length) list[54] = 5; | Check bounds. | Java |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
if ($foo = 99) {{}} | if ($foo -eq 99) {{}} | Use -eq. | PowerShell |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
def baz():
print('value') | def baz():
print('value') | Indent function body. | Python |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
values(58) | if length(values) >= 58, values(58), end | Check length. | MATLAB |
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.