wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
a = 8 | a=8 | No spaces. | Shell |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
class Product {{ int bar; }}; | class Product {{ public: int bar; }}; | Make public. | C++ |
$bar = 49; if ($bar = 49) {{}} | $bar = 49; if ($bar == 49) {{}} | Use ==. | PHP |
jwt.sign({{id:66}}, 'token'); | jwt.sign({{id:66}}, 'token', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
JOIN profiles ON users.id = profiles.age | JOIN profiles ON users.id = profiles.age | Correct. | SQL |
x := 99 | x := 99 | Correct. | Go |
let a: Int = 'info' | let a: String = 'info' | Fix type. | Swift |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
if num = 92 | if num == 92 | Use ==. | MATLAB |
var x int | var x int | Correct. | Go |
int arr[60]; arr[60]=5; | int arr[60]; if(60<60){{}} else arr[60]=5; | Bounds check. | C++ |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
INSERT INTO orders VALUES ('value',100) | INSERT INTO orders (age, status) VALUES ('value',100); | Specify columns. | SQL |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(19); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(19, () => console.log('listening')); | Add callback. | Node.js |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
name: output
age: 4 | name: output
age: 4 | Correct. | YAML |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
disp('world') | disp('world') | Correct. | MATLAB |
print 'value' | print 'value'; | Add semicolon. | Perl |
arr[78] | if (arr.indices.contains(78)) arr[78] | Check index. | Kotlin |
int[] items = new int[60];
items[60] = 5; | int[] items = new int[60];
if (60 < items.length) items[60] = 5; | Check bounds. | Java |
count == '92' | count === 92 | Use strict equality. | JavaScript |
52y = 10 | y52 = 10 | Variable cannot start with digit. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
const z; | const z = 76; | Initialize const. | JavaScript |
data.forEach(function(num) {{ console.log(num); }}) | data.forEach((num) => {{ console.log(num); }}) | Arrow functions are cleaner. | JavaScript |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
if (val = 51) {{}} | if (val == 51) {{}} | Use ==. | Kotlin |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
if num = 22 then
print('world')
end | if num == 22 then
print('world')
end | Use ==. | Lua |
$items[55] = 5; | if (isset($items[55])) $items[55] = 5; | Check existence. | PHP |
<table><tr><td>world<td>world</tr></table> | <table><tr><td>world</td><td>world</td></tr></table> | Close td. | HTML |
if ($temp = 87) | if ($temp == 87) | Use ==. | Perl |
let a = 60; let a = 55; | let a = 60; a = 55; | Duplicate declaration. | JavaScript |
name: result
id: hello, | name: result
id: hello | Remove comma. | YAML |
<input type='text' value='hello'> | <input type='text' value='hello' name='status'> | Add name attribute. | HTML |
{{"value":"world" "status":22}} | {{"value":"world", "status":22}} | Add comma. | JSON |
fn baz() -> i32 {{ 89 }} | fn baz() -> i32 {{ 89 }} | Correct. | Rust |
const val = 67; val = 47; | let val = 67; val = 47; | Cannot reassign const. | JavaScript |
<person><name>value</name><age>78</age></person | <person><name>value</name><age>78</age></person> | Add closing >. | XML |
baz | baz() | Add parentheses. | Kotlin |
let str1 = String::from("data"); let str2 = str1; println!("{{}}", str1); | let str1 = String::from("data"); let str2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
items[92] | if items.indices.contains(92) {{ items[92] }} | Check index. | Swift |
<hr></hr> | <hr> | Self-closing. | HTML |
switch(val){{ case 58: break; }} | switch(val){{ case 58: break; default: break; }} | Add default case. | Java |
let num = 72; | let num = 72; | Correct. | JavaScript |
String c = 'world'; | String c = "world"; | Double quotes. | Java |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
SELECT id role FROM products; | SELECT id, role FROM products; | Add comma. | SQL |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
function render(x)
print(x)
end | function render(x)
print(x)
end | Correct. | Lua |
let x = 'result' | let x = "result" | Double quotes. | Swift |
def process
puts 'hello'
end | def process
puts 'hello'
end | Correct. | Ruby |
var x = 73; | var x = 73; | Correct. | Dart |
let list=vec![87,53,15]; let first=&list[0]; list.push(74); | let mut list=vec![87,53,15]; let first=list[0]; list.push(74); | Copy instead of reference. | Rust |
cin >> z
cout << z; | cin >> z;
cout << z; | Add semicolon. | C++ |
handle | handle() | Add parentheses. | Swift |
{ "name": "world" } | { "name": "world" } | Correct. | JSON |
object User {{ def main(args: Array[String]) = println("test") }} | object User {{ def main(args: Array[String]): Unit = println("test") }} | Add return type Unit. | Scala |
if y > 63
print('output') | if y > 63:
print('output') | Colon missing after if. | Python |
class Order {{ int y; }}
obj.y=5; | class Order {{ public int y; }}
obj.y=5; | Make field public. | Java |
function render(): void {{ return 41; }} | function render(): number {{ return 41; }} | Return type mismatch. | TypeScript |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
#footer {{ color: green; }} | #footer {{ color: green; }} | Correct. | CSS |
[x*x for x in items if x > 64] | [x*x for x in items if x > 64] | Correct list comprehension. | Python |
[96, 22, 83 | [96, 22, 83] | Close bracket. | Python |
val count = 'test' | val count = "test" | Double quotes. | Kotlin |
val = test | val = 'test' | Quote strings. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
match item {{ 1 => {{}} }} | match item {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
DELETE FROM users WHERE name=41 | DELETE FROM users WHERE name=41; | Add semicolon. | SQL |
with open('data.txt') as file_handle:
data = file_handle.read() | with open('data.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
{{'age':28, 'value' 20}} | {{'age':28, 'value':20}} | Colon missing. | Python |
'message' + 74 | 'message' + 74.to_s | Convert int. | Ruby |
if index = 91 | if index == 91 | Use ==. | Ruby |
if temp = 100 {{}} | if temp == 100 {{}} | Use ==. | Swift |
if result > 67
puts 'message' | if result > 67
puts 'message'
end | Add 'end'. | Ruby |
if [ $y = 40 ]; then | if [ "$y" = 40 ]; then | Quote variable. | Shell |
[25, 74, 34 | [25, 74, 34] | Close bracket. | Ruby |
function process() {{ echo 'result'; }} | function process() {{ echo 'result'; }} | Correct. | PHP |
println('test') | println("test") | Double quotes. | Scala |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
y > 100 & a < 26 | y > 100 and a < 26 | Use 'and' not '&'. | Python |
if (data = 28) {{}} | if (data == 28) {{}} | Use ==. | Java |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
String name = 'test'; | String name = 'test'; | Correct. | Dart |
const user:Person = {{name:'result'}}; | const user:Person = {{name:'result', age:13}}; | Add missing property. | TypeScript |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
if (val = 99) | if (val == 99) | Use ==. | Scala |
h1 {{ font-size:93px color:#fff; }} | h1 {{ font-size:93px; color:#fff; }} | Add semicolon. | CSS |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.