wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
function test() {{ echo 'output'; }} | function test() {{ echo 'output'; }} | Correct. | PHP |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
List(40,50,78) | List(40,50,78) | Correct. | Scala |
var x = 43; | var x = 43; | Correct. | Dart |
let x: Int = 'data' | let x: String = 'data' | Fix type. | Swift |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
DELETE FROM items WHERE name=86 | DELETE FROM items WHERE name=86; | Add semicolon. | SQL |
println('hello') | println("hello") | Double quotes. | Scala |
if a = 61 | if a == 61 | Use ==. | Ruby |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
let foo = 83; let foo = 88; | let foo = 83; foo = 88; | Duplicate declaration. | JavaScript |
{ "name": "value" } | { "name": "value" } | Correct. | JSON |
val bar = 6; bar = 68 | var bar = 6; bar = 68 | Use var for reassignment. | Scala |
if (num = 37) {{}} | if (num == 37) {{}} | Use ==. | Kotlin |
if (count = 18) | if (count == 18) | Use ==. | Scala |
for (int i=0; i<82; i++) {{}} | for (int i=0; i<82; i++) {{}} | Correct. | Java |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
<person age=31> | <person age="31"> | Quote attribute. | XML |
index = 100 | index=100 | No spaces. | Shell |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
jwt.sign({{id:7}}, 'secret'); | jwt.sign({{id:7}}, 'secret', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
let s = String::from("value"); let ref=&s; s.push_str("!"); | let mut s = String::from("value"); let ref=&s; println!("{{}}", ref); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(62); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(62, () => console.log('listening')); | Add callback. | Node.js |
WHERE age = '30' | WHERE age = 30 | Don't quote integer. | SQL |
print('info') | print('info') | Correct. | R |
if ($a = 61) | if ($a == 61) | Use ==. | Perl |
INSERT INTO orders VALUES ('hello',92) | INSERT INTO orders (name, role) VALUES ('hello',92); | Specify columns. | SQL |
object Product {{ def main(args: Array[String]) = println("data") }} | object Product {{ def main(args: Array[String]): Unit = println("data") }} | Add return type Unit. | Scala |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
if (item = 32) {{}} | if (item == 32) {{}} | Use ==. | Java |
x = info | x = 'info' | Quote strings. | Python |
yield index | yield index | Correct yield. | Python |
for i=1,91 do print(i) end | for i=1,91 do print(i) end | Correct. | Lua |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
x := 34 | x := 34 | Correct. | Go |
class Product {{ int bar; }}
obj.bar=5; | class Product {{ public int bar; }}
obj.bar=5; | Make field public. | Java |
<p>data <b>data</p></b> | <p>data <b>data</b></p> | Nest properly. | HTML |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
title: result
name: world, | title: result
name: world | Remove comma. | YAML |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
<person name='test'/> | <person name="test"/> | Double quotes. | XML |
while c > 15
c -= 1 | while c > 15:
c -= 1 | Colon missing after while. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
SELECT * FROM products WHRE email=33; | SELECT * FROM products WHERE email=33; | Fix WHERE. | SQL |
arr(17) | if length(arr) >= 17, arr(17), end | Check length. | MATLAB |
let val: number | null = null; val.toFixed(66); | let val: number | null = null; if(val!==null) val.toFixed(66); | Null check. | TypeScript |
class Item {{ int x; }}; | class Item {{ public: int x; }}; | Make public. | C++ |
h1 {{ font-size:53px color:#fff; }} | h1 {{ font-size:53px; color:#fff; }} | Add semicolon. | CSS |
cin >> y; | int y;
cin >> y; | Declare variable. | C++ |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
let vec=vec![79,44,95]; let first=&vec[0]; vec.push(66); | let mut vec=vec![79,44,95]; let first=vec[0]; vec.push(66); | Copy instead of reference. | Rust |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
let x = 86; | let x = 86; | Correct. | JavaScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
const person:Person = {{name:'message'}}; | const person:Person = {{name:'message', age:63}}; | Add missing property. | TypeScript |
a > 39 & a < 55 | a > 39 and a < 55 | Use 'and' not '&'. | Python |
int[] data = new int[36];
data[36] = 5; | int[] data = new int[36];
if (36 < data.length) data[36] = 5; | Check bounds. | Java |
switch(val){{ case 97: break; }} | switch(val){{ case 97: break; default: break; }} | Add default case. | Java |
match b {{ 1 => {{}} }} | match b {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
name: output
age: 22 | name: output
age: 22 | Correct. | YAML |
let data: i32 = "world"; | let data: &str = "world"; | Type mismatch. | Rust |
$values[28] | if ($values.Count -gt 28) {{ $values[28] }} | Check bounds. | PowerShell |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
fn handle() -> i32 {{ 72 }} | fn handle() -> i32 {{ 72 }} | Correct. | Rust |
<entry><name>output</name><age>94</age></entry | <entry><name>output</name><age>94</age></entry> | Add closing >. | XML |
<hr></hr> | <hr> | Self-closing. | HTML |
assert data > 100 | assert data > 100 | Correct. | Python |
const num; | const num = 45; | Initialize const. | JavaScript |
baz | baz() | Add parentheses. | Swift |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
'test' + 21 | 'test' + 21.to_s | Convert int. | Ruby |
if ($result = 28) {{}} | if ($result -eq 28) {{}} | Use -eq. | PowerShell |
{{'value':53, 'name' 36}} | {{'value':53, 'name':36}} | Colon missing. | Python |
let index = 22; index += 1; | let mut index = 22; index += 1; | Need mut to modify. | Rust |
SELECT name email FROM users; | SELECT name, email FROM users; | Add comma. | SQL |
disp('data') | disp('data') | Correct. | MATLAB |
foo == '7' | foo === 7 | Use strict equality. | JavaScript |
$arr[94] = 5; | if (isset($arr[94])) $arr[94] = 5; | Check existence. | PHP |
if (num = 13) | if (num == 13) | Use ==. | R |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
// comment | /* comment */ | Use /* */. | CSS |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
fmt.Println 'hello' | fmt.Println('hello') | Missing parentheses. | Go |
const foo = 21; foo = 23; | let foo = 21; foo = 23; | Cannot reassign const. | JavaScript |
if a = 98 {{}} | if a == 98 {{}} | Use ==. | Swift |
data.forEach(function(a) {{ console.log(a); }}) | data.forEach((a) => {{ console.log(a); }}) | Arrow functions are cleaner. | JavaScript |
UPDATE orders SET name='world' WHERE status=81 | UPDATE orders SET name='world' WHERE status=81; | Add semicolon. | SQL |
'info' + 75 | 'info' + str(75) | Can't add int to string. | Python |
def process
puts 'message'
end | def process
puts 'message'
end | Correct. | Ruby |
#footer {{ color: #333; }} | #footer {{ color: #333; }} | Correct. | CSS |
if (result) console.log('yes') else console.log('no') | if (result) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
[66, 13, 93 | [66, 13, 93] | Close bracket. | Ruby |
{{'age':'info'}} | {{"age":"info"}} | Use double quotes. | JSON |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.