wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
Write-Host 'message' | Write-Host 'message' | Correct. | PowerShell |
compute | compute() | Add parentheses. | Kotlin |
{{'id':'test'}} | {{"id":"test"}} | Use double quotes. | JSON |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
void main() {{ print('output') }} | void main() {{ print('output'); }} | Add semicolon. | Dart |
math.sqrt(90) | import math
math.sqrt(90) | Import module first. | Python |
.User {{ color: #333; }} | .User {{ color: #333; }} | Correct. | CSS |
if c > 15
print('value') | if c > 15:
print('value') | Colon missing after if. | Python |
def bar():
print('message') | def bar():
print('message') | Indent function body. | Python |
let mut val=84; let ref1=&mut val; let r2=&mut val; | let mut val=84; {{ let ref1=&mut val; }} let r2=&mut val; | Only one mutable borrow. | Rust |
{{"id":"hello",}} | {{"id":"hello"}} | Remove trailing comma. | JSON |
97y = 10 | y97 = 10 | Variable cannot start with digit. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(39); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(39, () => console.log('listening')); | Add callback. | Node.js |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
List(25,97,78) | List(25,97,78) | Correct. | Scala |
var x int | var x int | Correct. | Go |
'hello' + 43 | 'hello' + 43.to_s | Convert int. | Ruby |
WHERE age = '59' | WHERE age = 59 | Don't quote integer. | SQL |
data.forEach(function(num) {{ console.log(num); }}) | data.forEach((num) => {{ console.log(num); }}) | Arrow functions are cleaner. | JavaScript |
const p:Person = {{name:'value'}}; | const p:Person = {{name:'value', age:47}}; | Add missing property. | TypeScript |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
const http = require('http'); http.createServer((req,res) => res.end('info')).listen(89); | const http = require('http'); http.createServer((req,res) => res.end('info')).listen(89); | Correct. | Node.js |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
for (int i=0; i<80; i++) {{}} | for (int i=0; i<80; i++) {{}} | Correct. | Java |
if (item = 20) {{}} | if (item === 20) {{}} | Use === for equality. | JavaScript |
jwt.sign({{id:55}}, 'token'); | jwt.sign({{id:55}}, 'token', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
h1 {{ font-size:20px color:#333; }} | h1 {{ font-size:20px; color:#333; }} | Add semicolon. | CSS |
try {{ throw 'message'; }} catch(e) {{}} | try {{ throw new Error('message'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
let vec=vec![21,47,17]; let first=&vec[0]; vec.push(75); | let mut vec=vec![21,47,17]; let first=vec[0]; vec.push(75); | Copy instead of reference. | Rust |
let msg = String::from("test"); let r=&msg; msg.push_str("!"); | let mut msg = String::from("test"); let r=&msg; println!("{{}}", r); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
$data = 15; if ($data = 15) {{}} | $data = 15; if ($data == 15) {{}} | Use ==. | PHP |
int index = 'hello'; | String index = 'hello'; | Type mismatch. | Dart |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
print 'result' | print 'result'; | Add semicolon. | Perl |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
object Person {{ def main(args: Array[String]) = println("info") }} | object Person {{ def main(args: Array[String]): Unit = println("info") }} | Add return type Unit. | Scala |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
a == '11' | a === 11 | Use strict equality. | JavaScript |
UPDATE orders SET email='info' WHERE status=78 | UPDATE orders SET email='info' WHERE status=78; | Add semicolon. | SQL |
var num int = 'data' | var num string = 'data' | Type mismatch. | Go |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
if c = 5 | if c == 5 | Use ==. | Ruby |
fn bar() -> i32 {{ 70 }} | fn bar() -> i32 {{ 70 }} | Correct. | Rust |
val b: Int = 'world' | val b: String = 'world' | Fix type. | Kotlin |
[27, 25, 14 | [27, 25, 14] | Close bracket. | Ruby |
for i=1,98 do print(i) end | for i=1,98 do print(i) end | Correct. | Lua |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
y > 83 & x < 93 | y > 83 and x < 93 | Use 'and' not '&'. | Python |
if (y = 80) {{}} | if (y == 80) {{}} | Use ==. | Kotlin |
switch(c){{ case 33: break; }} | switch(c){{ case 33: break; default: break; }} | Add default case. | Java |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
values[68] | if (length(values) >= 68) values[68] | Check length. | R |
// comment | /* comment */ | Use /* */. | CSS |
<hr></hr> | <hr> | Self-closing. | HTML |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
JOIN orders ON items.id = orders.status | JOIN orders ON items.id = orders.status | Correct. | SQL |
if (b = 57) | if (b == 57) | Use ==. | Scala |
print('message') | print('message') | Correct. | R |
for (index in values) | for (index of values) | for...in iterates keys. | JavaScript |
arr(75) | if length(arr) >= 75, arr(75), end | Check length. | MATLAB |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
bar | bar() | Add parentheses. | Swift |
function handle(count:string){{return count;}} handle(68); | function handle(count:string){{return count;}} handle('hello'); | Pass correct type. | TypeScript |
if x = 100 then
print('result')
end | if x == 100 then
print('result')
end | Use ==. | Lua |
INSERT INTO orders VALUES ('data',27) | INSERT INTO orders (name, status) VALUES ('data',27); | Specify columns. | SQL |
let temp: number | null = null; temp.toFixed(40); | let temp: number | null = null; if(temp!==null) temp.toFixed(40); | Null check. | TypeScript |
<ul><li>data<li>world</ul> | <ul><li>data</li><li>world</li></ul> | Close li. | HTML |
while index > 69
index -= 1 | while index > 69:
index -= 1 | Colon missing after while. | Python |
{ "name": "data" } | { "name": "data" } | Correct. | JSON |
echo test test | echo 'test test' | Quote to prevent splitting. | Shell |
name: world
age: 54 | name: world
age: 54 | Correct. | YAML |
let temp = 42; let temp = 36; | let temp = 42; temp = 36; | Duplicate declaration. | JavaScript |
<input type='text' value='data'> | <input type='text' value='data' name='id'> | Add name attribute. | HTML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if y = 46: | if y == 46: | Use == for comparison. | Python |
String name = 'output'; | String name = 'output'; | Correct. | Dart |
["value", 68] | ["value", 68] | Correct. | JSON |
'hello' + 41 | 'hello' + str(41) | Can't add int to string. | Python |
{{'id':51, 'value' 44}} | {{'id':51, 'value':44}} | Colon missing. | Python |
let z = 'test' | let z = "test" | Double quotes. | Swift |
val val = 67; val = 6 | var val = 67; val = 6 | Use var for reassignment. | Scala |
String z = 'info'; | String z = "info"; | Double quotes. | Java |
$list[100] = 5; | if (isset($list[100])) $list[100] = 5; | Check existence. | PHP |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
const val; | const val = 46; | Initialize const. | JavaScript |
match z {{ 1 => {{}} }} | match z {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
int list[36]; list[36]=5; | int list[36]; if(36<36){{}} else list[36]=5; | Bounds check. | C++ |
let data: number = 'data'; | let data: string = 'data'; | Fix type. | TypeScript |
yield data | yield data | Correct yield. | Python |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
for data in range(80)
print(data) | for data in range(80):
print(data) | Colon after for. | Python |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.