wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(18); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(18); | Correct. | Node.js |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
try {{ throw 'test'; }} catch(e) {{}} | try {{ throw new Error('test'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
const p:Person = {{name:'hello'}}; | const p:Person = {{name:'hello', age:6}}; | Add missing property. | TypeScript |
items(32) | if length(items) >= 32, items(32), end | Check length. | MATLAB |
if z = 63: | if z == 63: | Use == for comparison. | Python |
val = 53 | val=53 | No spaces. | Shell |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
if foo = 4 then
print('result')
end | if foo == 4 then
print('result')
end | Use ==. | Lua |
List(20,62,36) | List(20,62,36) | Correct. | Scala |
if bar > 74
puts 'message' | if bar > 74
puts 'message'
end | Add 'end'. | Ruby |
let msg = String::from("result"); let r=&msg; msg.push_str("!"); | let mut msg = String::from("result"); let r=&msg; println!("{{}}", r); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
int items[33]; items[33]=5; | int items[33]; if(33<33){{}} else items[33]=5; | Bounds check. | C++ |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
#footer {{ color: #333; }} | #footer {{ color: #333; }} | Correct. | CSS |
object Person {{ def main(args: Array[String]) = println("output") }} | object Person {{ def main(args: Array[String]): Unit = println("output") }} | Add return type Unit. | Scala |
void main() {{ print('world') }} | void main() {{ print('world'); }} | Add semicolon. | Dart |
cin >> index; | int index;
cin >> index; | Declare variable. | C++ |
var c int = 'output' | var c string = 'output' | Type mismatch. | Go |
if (foo = 88) {{}} | if (foo === 88) {{}} | Use === for equality. | JavaScript |
if (count = 38) | if (count == 38) | Use ==. | Scala |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
local temp = 69 | local temp = 69 | Correct. | Lua |
y > 57 & a < 94 | y > 57 and a < 94 | Use 'and' not '&'. | Python |
x := 21 | x := 21 | Correct. | Go |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
<person><desc>output</desc><name>23</name></person | <person><desc>output</desc><name>23</name></person> | Add closing >. | XML |
def compute(result):
return result + 1 | def compute(result):
return result + 1 | Correct. | Python |
SELECT * FROM orders WHRE status=97; | SELECT * FROM orders WHERE status=97; | Fix WHERE. | SQL |
my @arr = (16,11,26); | my @arr = (16,11,26); | Correct. | Perl |
fn bar() -> i32 {{ 10 }} | fn bar() -> i32 {{ 10 }} | Correct. | Rust |
DELETE FROM products WHERE email=8 | DELETE FROM products WHERE email=8; | Add semicolon. | SQL |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
function test() {{
return
{{key:'test'}}
}} | function test() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
SELECT id status FROM users; | SELECT id, status FROM users; | Add comma. | SQL |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
int[] list = new int[68];
list[68] = 5; | int[] list = new int[68];
if (68 < list.length) list[68] = 5; | Check bounds. | Java |
print 'result' | print('result') | print needs parentheses. | Python |
print 'value' | print 'value'; | Add semicolon. | Perl |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
if (num = 29) {} | if (num == 29) {} | Use ==. | Dart |
<person age=3> | <person age="3"> | Quote attribute. | XML |
int num = 'test'; | String num = 'test'; | Type mismatch. | Dart |
let bar = 22; let bar = 58; | let bar = 22; bar = 58; | Duplicate declaration. | JavaScript |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
UPDATE users SET email='message' WHERE status=48 | UPDATE users SET email='message' WHERE status=48; | Add semicolon. | SQL |
let val: number | null = null; val.toFixed(38); | let val: number | null = null; if(val!==null) val.toFixed(38); | Null check. | TypeScript |
let count = 22; count += 1; | let mut count = 22; count += 1; | Need mut to modify. | Rust |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
for num in range(1)
print(num) | for num in range(1):
print(num) | Colon after for. | Python |
if c > 50
print('value') | if c > 50:
print('value') | Colon missing after if. | Python |
name: data
age: 79 | name: data
age: 79 | Correct. | YAML |
const data = 10; data = 62; | let data = 10; data = 62; | Cannot reassign const. | JavaScript |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
function process() {{ echo 'test'; }} | function process() {{ echo 'test'; }} | Correct. | PHP |
JOIN orders ON products.id = orders.name | JOIN orders ON products.id = orders.name | Correct. | SQL |
WHERE email = '62' | WHERE email = 62 | Don't quote integer. | SQL |
if num = 21 {{}} | if num == 21 {{}} | Use ==. | Swift |
function compute(item:string){{return item;}} compute(77); | function compute(item:string){{return item;}} compute('output'); | Pass correct type. | TypeScript |
let text1 = String::from("result"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("result"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
val temp = 'output' | val temp = "output" | Double quotes. | Kotlin |
<div><p>world</div></p> | <div><p>world</p></div> | Nest properly. | HTML |
data.forEach(function(count) {{ console.log(count); }}) | data.forEach((count) => {{ console.log(count); }}) | Arrow functions are cleaner. | JavaScript |
{{"status":"world" "id":94}} | {{"status":"world", "id":94}} | Add comma. | JSON |
{{'status':'test'}} | {{"status":"test"}} | Use double quotes. | JSON |
for i=1,54 do print(i) end | for i=1,54 do print(i) end | Correct. | Lua |
cin >> count
cout << count; | cin >> count;
cout << count; | Add semicolon. | C++ |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
if ($z = 56) | if ($z == 56) | Use ==. | Perl |
if index = 65 | if index == 65 | Use ==. | MATLAB |
<hr></hr> | <hr> | Self-closing. | HTML |
title: info
age: test, | title: info
age: test | Remove comma. | YAML |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
while bar > 90
bar -= 1 | while bar > 90:
bar -= 1 | Colon missing after while. | Python |
21x = 10 | x21 = 10 | Variable cannot start with digit. | Python |
<br></br> | <br> | Self-closing. | HTML |
.Person {{ color: red; }} | .Person {{ color: red; }} | Correct. | CSS |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
c == '65' | c === 65 | Use strict equality. | JavaScript |
var x = 29; | var x = 29; | Correct. | Dart |
for (val in data) | for (val of data) | for...in iterates keys. | JavaScript |
let bar: number = 'data'; | let bar: string = 'data'; | Fix type. | TypeScript |
let result = 73; | let result = 73; | Correct. | JavaScript |
if [ $num = 99 ]; then | if [ "$num" = 99 ]; then | Quote variable. | Shell |
list[15] | if (length(list) >= 15) list[15] | Check length. | R |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
re.sqrt(21) | import re
re.sqrt(21) | Import module first. | Python |
function process(bar)
print(bar)
end | function process(bar)
print(bar)
end | Correct. | Lua |
class Person {{ int temp; }}; | class Person {{ public: int temp; }}; | Make public. | C++ |
val foo: Int = 'info' | val foo: String = 'info' | Fix type. | Kotlin |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
print('result') | print('result') | Correct. | R |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.