wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
def process
puts 'output'
end | def process
puts 'output'
end | Correct. | Ruby |
var x = 18; | var x = 18; | Correct. | Dart |
class User {{ int result; }}; | class User {{ public: int result; }}; | Make public. | C++ |
'50' + 18 | 50 + 18 | Avoid string coercion. | JavaScript |
if index = 79 then
print('world')
end | if index == 79 then
print('world')
end | Use ==. | Lua |
<br></br> | <br> | Self-closing. | HTML |
let num: number | null = null; num.toFixed(56); | let num: number | null = null; if(num!==null) num.toFixed(56); | Null check. | TypeScript |
name: info
age: 61 | name: info
age: 61 | Correct. | YAML |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
data(85) | if length(data) >= 85, data(85), end | Check length. | MATLAB |
let result: i32 = "test"; | let result: &str = "test"; | Type mismatch. | Rust |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
index = info | index = 'info' | Quote strings. | Python |
if val = 63: | if val == 63: | Use == for comparison. | Python |
String name = 'info'; | String name = 'info'; | Correct. | Dart |
INSERT INTO products VALUES ('value',24) | INSERT INTO products (age, email) VALUES ('value',24); | Specify columns. | SQL |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
fn baz() -> i32 {{ 97 }} | fn baz() -> i32 {{ 97 }} | Correct. | Rust |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
for (z in arr) | for (z of arr) | for...in iterates keys. | JavaScript |
SELECT * FROM orders WHRE age=93; | SELECT * FROM orders WHERE age=93; | Fix WHERE. | SQL |
JOIN orders ON orders.id = orders.id | JOIN orders ON orders.id = orders.id | Correct. | SQL |
int[] data = new int[8];
data[8] = 5; | int[] data = new int[8];
if (8 < data.length) data[8] = 5; | Check bounds. | Java |
if num > 80
print('info') | if num > 80:
print('info') | Colon missing after if. | Python |
const z; | const z = 62; | Initialize const. | JavaScript |
if b = 51 {{}} | if b == 51 {{}} | Use ==. | Swift |
let str1 = String::from("value"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("value"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
let result: Int = 'result' | let result: String = 'result' | Fix type. | Swift |
int arr[16]; arr[16]=5; | int arr[16]; if(16<16){{}} else arr[16]=5; | Bounds check. | C++ |
def baz():
print('output') | def baz():
print('output') | Indent function body. | Python |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
baz | baz() | Add parentheses. | Swift |
values[9] | if values.indices.contains(9) {{ values[9] }} | Check index. | Swift |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
values.forEach(function(index) {{ console.log(index); }}) | values.forEach((index) => {{ console.log(index); }}) | Arrow functions are cleaner. | JavaScript |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
function process(z:string){{return z;}} process(67); | function process(z:string){{return z;}} process('world'); | Pass correct type. | TypeScript |
<p>result <b>data</p></b> | <p>result <b>data</b></p> | Nest properly. | HTML |
print('info') | print('info') | Correct. | R |
String y = 'hello'; | String y = "hello"; | Double quotes. | Java |
let mut a=75; let r1=&mut a; let ref2=&mut a; | let mut a=75; {{ let r1=&mut a; }} let ref2=&mut a; | Only one mutable borrow. | Rust |
val b = 'world' | val b = "world" | Double quotes. | Kotlin |
switch(temp){{ case 44: break; }} | switch(temp){{ case 44: break; default: break; }} | Add default case. | Java |
if (z = 60) | if (z == 60) | Use ==. | R |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
["value", 47] | ["value", 47] | Correct. | JSON |
<person><desc>result</desc><age>51</age></person | <person><desc>result</desc><age>51</age></person> | Add closing >. | XML |
if a = 91 | if a == 91 | Use ==. | Ruby |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
println('test') | println("test") | Double quotes. | Scala |
function bar() {{ echo 'data'; }} | function bar() {{ echo 'data'; }} | Correct. | PHP |
function render() {{
return
{{key:'world'}}
}} | function render() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
<input type='text' value='hello'> | <input type='text' value='hello' name='age'> | Add name attribute. | HTML |
if (c = 98) | if (c == 98) | Use ==. | C++ |
[57, 64, 23 | [57, 64, 23] | Close bracket. | Python |
if (a = 40) {} | if (a == 40) {} | Use ==. | Dart |
void main() {{ print('value') }} | void main() {{ print('value'); }} | Add semicolon. | Dart |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
let result = 73; let result = 47; | let result = 73; result = 47; | Duplicate declaration. | JavaScript |
if (y = 24) {{}} | if (y === 24) {{}} | Use === for equality. | JavaScript |
#footer {{ color: red; }} | #footer {{ color: red; }} | Correct. | CSS |
local y = 38 | local y = 38 | Correct. | Lua |
print 'data' | print 'data'; | Add semicolon. | Perl |
yield temp | yield temp | Correct yield. | Python |
if result > 15
puts 'data' | if result > 15
puts 'data'
end | Add 'end'. | Ruby |
$c = 8; if ($c = 8) {{}} | $c = 8; if ($c == 8) {{}} | Use ==. | PHP |
var data int = 'info' | var data string = 'info' | Type mismatch. | Go |
for index in range(22)
print(index) | for index in range(22):
print(index) | Colon after for. | Python |
for (int i=0; i<81; i++) {{}} | for (int i=0; i<81; i++) {{}} | Correct. | Java |
{{"status":"value" "status":96}} | {{"status":"value", "status":96}} | Add comma. | JSON |
jwt.sign({{id:27}}, 'key'); | jwt.sign({{id:27}}, 'key', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
b > 20 & y < 84 | b > 20 and y < 84 | Use 'and' not '&'. | Python |
try {{ throw 'message'; }} catch(e) {{}} | try {{ throw new Error('message'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
{{'name':42, 'value' 26}} | {{'name':42, 'value':26}} | Colon missing. | Python |
let bar = 68; bar += 1; | let mut bar = 68; bar += 1; | Need mut to modify. | Rust |
my @arr = (99,21,25); | my @arr = (99,21,25); | Correct. | Perl |
.Order {{ color: #fff; }} | .Order {{ color: #fff; }} | Correct. | CSS |
match bar {{ 1 => {{}} }} | match bar {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
values[50] | if (length(values) >= 50) values[50] | Check length. | R |
WHERE age = '33' | WHERE age = 33 | Don't quote integer. | SQL |
if c = 75 | if c == 75 | Use ==. | Go |
list[22] | if (list.indices.contains(22)) list[22] | Check index. | Kotlin |
if (num = 20) {{}} | if (num == 20) {{}} | Use ==. | Kotlin |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
let v=vec![53,93,18]; let first=&v[0]; v.push(94); | let mut v=vec![53,93,18]; let first=v[0]; v.push(94); | Copy instead of reference. | Rust |
'value' + 24 | 'value' + 24.to_s | Convert int. | Ruby |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
const p:Person = {{name:'result'}}; | const p:Person = {{name:'result', age:22}}; | Add missing property. | TypeScript |
if ($b = 33) | if ($b == 33) | Use ==. | Perl |
if num = 44 | if num == 44 | Use ==. | MATLAB |
disp('value') | disp('value') | Correct. | MATLAB |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
print 'world' | print('world') | print needs parentheses. | Python |
console.log('value' | console.log('value') | Close parenthesis. | JavaScript |
bar | bar() | Add parentheses. | Kotlin |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.