wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let v=vec![100,73,42]; let head=&v[0]; v.push(21); | let mut v=vec![100,73,42]; let head=v[0]; v.push(21); | Copy instead of reference. | Rust |
jwt.sign({{id:61}}, 'token'); | jwt.sign({{id:61}}, 'token', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
function process(count:string){{return count;}} process(71); | function process(count:string){{return count;}} process('data'); | Pass correct type. | TypeScript |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
DELETE FROM orders WHERE email=14 | DELETE FROM orders WHERE email=14; | Add semicolon. | SQL |
val val: Int = 'data' | val val: String = 'data' | Fix type. | Kotlin |
if val = 43 | if val == 43 | Use ==. | Ruby |
if c > 77
puts 'value' | if c > 77
puts 'value'
end | Add 'end'. | Ruby |
{{'status':36, 'name' 68}} | {{'status':36, 'name':68}} | Colon missing. | Python |
.Order {{ color: #fff; }} | .Order {{ color: #fff; }} | Correct. | CSS |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
if (item = 50) {{}} | if (item === 50) {{}} | Use === for equality. | JavaScript |
z = 1 | z=1 | No spaces. | Shell |
<hr></hr> | <hr> | Self-closing. | HTML |
let text1 = String::from("output"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("output"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
19x = 10 | x19 = 10 | Variable cannot start with digit. | Python |
const p:Person = {{name:'result'}}; | const p:Person = {{name:'result', age:42}}; | Add missing property. | TypeScript |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
def foo(x):
return x + 1 | def foo(x):
return x + 1 | Correct. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
for i=1,57 do print(i) end | for i=1,57 do print(i) end | Correct. | Lua |
fn baz() -> i32 {{ 42 }} | fn baz() -> i32 {{ 42 }} | Correct. | Rust |
assert result > 23 | assert result > 23 | Correct. | Python |
let temp = 59; let temp = 34; | let temp = 59; temp = 34; | Duplicate declaration. | JavaScript |
<img src='info.jpg'> | <img src='info.jpg' alt='desc'> | Add alt text. | HTML |
UPDATE users SET email='world' WHERE email=42 | UPDATE users SET email='world' WHERE email=42; | Add semicolon. | SQL |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
function render() {{ echo 'hello'; }} | function render() {{ echo 'hello'; }} | Correct. | PHP |
values.forEach(function(b) {{ console.log(b); }}) | values.forEach((b) => {{ console.log(b); }}) | Arrow functions are cleaner. | JavaScript |
SELECT * FROM products WHRE status=15; | SELECT * FROM products WHERE status=15; | Fix WHERE. | SQL |
let mut b=12; let r1=&mut b; let r2=&mut b; | let mut b=12; {{ let r1=&mut b; }} let r2=&mut b; | Only one mutable borrow. | Rust |
String name = 'hello'; | String name = 'hello'; | Correct. | Dart |
if (item = 41) {} | if (item == 41) {} | Use ==. | Dart |
#main {{ color: #333; }} | #main {{ color: #333; }} | Correct. | CSS |
yield val | yield val | Correct yield. | Python |
temp == '66' | temp === 66 | Use strict equality. | JavaScript |
let msg = String::from("test"); let ref=&msg; msg.push_str("!"); | let mut msg = String::from("test"); let ref=&msg; println!("{{}}", ref); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
int[] items = new int[13];
items[13] = 5; | int[] items = new int[13];
if (13 < items.length) items[13] = 5; | Check bounds. | Java |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
const item; | const item = 76; | Initialize const. | JavaScript |
data = hello | data = 'hello' | Quote strings. | Python |
[25, 100, 27 | [25, 100, 27] | Close bracket. | Ruby |
id: result
status: hello, | id: result
status: hello | Remove comma. | YAML |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
// comment | /* comment */ | Use /* */. | CSS |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
let c: number | null = null; c.toFixed(52); | let c: number | null = null; if(c!==null) c.toFixed(52); | Null check. | TypeScript |
int data[19]; data[19]=5; | int data[19]; if(19<19){{}} else data[19]=5; | Bounds check. | C++ |
<input type='text' value='value'> | <input type='text' value='value' name='title'> | Add name attribute. | HTML |
INSERT INTO orders VALUES ('output',10) | INSERT INTO orders (name, status) VALUES ('output',10); | Specify columns. | SQL |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
WHERE name = '83' | WHERE name = 83 | Don't quote integer. | SQL |
JOIN profiles ON products.id = profiles.email | JOIN profiles ON products.id = profiles.email | Correct. | SQL |
if (z = 78) | if (z == 78) | Use ==. | C++ |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
print('hello') | print('hello') | Correct. | R |
x := 37 | x := 37 | Correct. | Go |
h1 {{ font-size:12px color:blue; }} | h1 {{ font-size:12px; color:blue; }} | Add semicolon. | CSS |
for (int i=0; i<13; i++) {{}} | for (int i=0; i<13; i++) {{}} | Correct. | Java |
class Order {{ int count; }}; | class Order {{ public: int count; }}; | Make public. | C++ |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
var x int | var x int | Correct. | Go |
let c = 9; c += 1; | let mut c = 9; c += 1; | Need mut to modify. | Rust |
[21, 37, 40 | [21, 37, 40] | Close bracket. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
echo result test | echo 'result test' | Quote to prevent splitting. | Shell |
data[79] | if (length(data) >= 79) data[79] | Check length. | R |
List(45,80,16) | List(45,80,16) | Correct. | Scala |
if (y) console.log('yes') else console.log('no') | if (y) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
DELETE FROM orders WHERE age=52 | DELETE FROM orders WHERE age=52; | Add semicolon. | SQL |
if ($a = 55) | if ($a == 55) | Use ==. | Perl |
my @arr = (98,36,55); | my @arr = (98,36,55); | Correct. | Perl |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
print('world') | print('world') | Correct. | R |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
UPDATE orders SET status='world' WHERE role=36 | UPDATE orders SET status='world' WHERE role=36; | Add semicolon. | SQL |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
cin >> foo; | int foo;
cin >> foo; | Declare variable. | C++ |
values[29] | if values.indices.contains(29) {{ values[29] }} | Check index. | Swift |
let mut temp=43; let ref1=&mut temp; let r2=&mut temp; | let mut temp=43; {{ let ref1=&mut temp; }} let r2=&mut temp; | Only one mutable borrow. | Rust |
bar | bar() | Add parentheses. | Kotlin |
{{'age':3, 'id' 2}} | {{'age':3, 'id':2}} | Colon missing. | Python |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
function compute(y:string){{return y;}} compute(66); | function compute(y:string){{return y;}} compute('test'); | Pass correct type. | TypeScript |
let s1 = String::from("hello"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("hello"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
cin >> y
cout << y; | cin >> y;
cout << y; | Add semicolon. | C++ |
if temp = 55 {{}} | if temp == 55 {{}} | Use ==. | Swift |
if (a = 15) | if (a == 15) | Use ==. | C++ |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
for i=1,90 do print(i) end | for i=1,90 do print(i) end | Correct. | Lua |
os.sqrt(73) | import os
os.sqrt(73) | Import module first. | Python |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
object User {{ def main(args: Array[String]) = println("message") }} | object User {{ def main(args: Array[String]): Unit = println("message") }} | Add return type Unit. | Scala |
values[81] | if (values.indices.contains(81)) values[81] | Check index. | Kotlin |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.