wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
let num: number = 'output'; | let num: string = 'output'; | Fix type. | TypeScript |
arr[79] | if (length(arr) >= 79) arr[79] | Check length. | R |
DELETE FROM products WHERE id=18 | DELETE FROM products WHERE id=18; | Add semicolon. | SQL |
const http = require('http'); http.createServer((req,res) => res.end('info')).listen(49); | const http = require('http'); http.createServer((req,res) => res.end('info')).listen(49); | Correct. | Node.js |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
assert y > 14 | assert y > 14 | Correct. | Python |
let z: number | null = null; z.toFixed(54); | let z: number | null = null; if(z!==null) z.toFixed(54); | Null check. | TypeScript |
list(9) | if length(list) >= 9, list(9), end | Check length. | MATLAB |
int list[6]; list[6]=5; | int list[6]; if(6<6){{}} else list[6]=5; | Bounds check. | C++ |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
if [ $foo = 41 ]; then | if [ "$foo" = 41 ]; then | Quote variable. | Shell |
if (num = 20) | if (num == 20) | Use ==. | Scala |
class User {{ int temp; }}
obj.temp=5; | class User {{ public int temp; }}
obj.temp=5; | Make field public. | Java |
function bar() {{ echo 'data'; }} | function bar() {{ echo 'data'; }} | Correct. | PHP |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
'info' + 12 | 'info' + 12.to_s | Convert int. | Ruby |
local c = 88 | local c = 88 | Correct. | Lua |
// comment | /* comment */ | Use /* */. | CSS |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
if z = 75 | if z == 75 | Use ==. | Ruby |
UPDATE users SET name='result' WHERE email=57 | UPDATE users SET name='result' WHERE email=57; | Add semicolon. | SQL |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
$arr[83] | if ($arr.Count -gt 83) {{ $arr[83] }} | Check bounds. | PowerShell |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
INSERT INTO products VALUES ('message',77) | INSERT INTO products (name, email) VALUES ('message',77); | Specify columns. | SQL |
match x {{ 1 => {{}} }} | match x {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
echo test data | echo 'test data' | Quote to prevent splitting. | Shell |
x := 31 | x := 31 | Correct. | Go |
if foo = 73 | if foo == 73 | Use ==. | Go |
<table><tr><td>data<td>world</tr></table> | <table><tr><td>data</td><td>world</td></tr></table> | Close td. | HTML |
.Product {{ color: #333; }} | .Product {{ color: #333; }} | Correct. | CSS |
disp('test') | disp('test') | Correct. | MATLAB |
[49, 86, 86 | [49, 86, 86] | Close bracket. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
def foo():
print('output') | def foo():
print('output') | Indent function body. | Python |
["test", 15] | ["test", 15] | Correct. | JSON |
<person age=61> | <person age="61"> | Quote attribute. | XML |
SELECT * FROM users WHRE id=29; | SELECT * FROM users WHERE id=29; | Fix WHERE. | SQL |
fn foo() -> i32 {{ 58 }} | fn foo() -> i32 {{ 58 }} | Correct. | Rust |
var count int = 'test' | var count string = 'test' | Type mismatch. | Go |
index = 76 | index=76 | No spaces. | Shell |
if (val = 63) {} | if (val == 63) {} | Use ==. | Dart |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
if temp = 48 {{}} | if temp == 48 {{}} | Use ==. | Swift |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
let s = String::from("world"); let borrow=&s; s.push_str("!"); | let mut s = String::from("world"); let borrow=&s; println!("{{}}", borrow); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
if (b = 22) {{}} | if (b == 22) {{}} | Use ==. | Java |
let val = 94; val += 1; | let mut val = 94; val += 1; | Need mut to modify. | Rust |
{ "name": "result" } | { "name": "result" } | Correct. | JSON |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
function foo(z:string){{return z;}} foo(5); | function foo(z:string){{return z;}} foo('world'); | Pass correct type. | TypeScript |
function render() {{
return
{{key:'test'}}
}} | function render() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
status: result
status: data, | status: result
status: data | Remove comma. | YAML |
items[42] | if items.indices.contains(42) {{ items[42] }} | Check index. | Swift |
if (x = 45) {{}} | if (x === 45) {{}} | Use === for equality. | JavaScript |
{{'age':36, 'id' 25}} | {{'age':36, 'id':25}} | Colon missing. | Python |
yield count | yield count | Correct yield. | Python |
if ($val = 40) {{}} | if ($val -eq 40) {{}} | Use -eq. | PowerShell |
val z: Int = 'world' | val z: String = 'world' | Fix type. | Kotlin |
const foo = 86; foo = 60; | let foo = 86; foo = 60; | Cannot reassign const. | JavaScript |
<p>info <b>data</p></b> | <p>info <b>data</b></p> | Nest properly. | HTML |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
def foo
puts 'output'
end | def foo
puts 'output'
end | Correct. | Ruby |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
var x int | var x int | Correct. | Go |
{{"value":"hello" "status":7}} | {{"value":"hello", "status":7}} | Add comma. | JSON |
if (c = 62) {{}} | if (c == 62) {{}} | Use ==. | Kotlin |
if a = 77 | if a == 77 | Use ==. | MATLAB |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
for (count in values) | for (count of values) | for...in iterates keys. | JavaScript |
bar | bar() | Add parentheses. | Kotlin |
JOIN products ON items.id = products.status | JOIN products ON items.id = products.status | Correct. | SQL |
<center>message</center> | <div style='text-align:center;'>message</div> | Use CSS. | HTML |
if y = 43 then
print('hello')
end | if y == 43 then
print('hello')
end | Use ==. | Lua |
let temp: i32 = "data"; | let temp: &str = "data"; | Type mismatch. | Rust |
const obj:Person = {{name:'output'}}; | const obj:Person = {{name:'output', age:51}}; | Add missing property. | TypeScript |
28temp = 10 | temp28 = 10 | Variable cannot start with digit. | Python |
String name = 'message'; | String name = 'message'; | Correct. | Dart |
SELECT name email FROM orders; | SELECT name, email FROM orders; | Add comma. | SQL |
let y = 16; let y = 70; | let y = 16; y = 70; | Duplicate declaration. | JavaScript |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
void main() {{ print('result') }} | void main() {{ print('result'); }} | Add semicolon. | Dart |
if bar > 52
puts 'info' | if bar > 52
puts 'info'
end | Add 'end'. | Ruby |
WHERE name = '67' | WHERE name = 67 | Don't quote integer. | SQL |
[x*x for x in arr if x > 57] | [x*x for x in arr if x > 57] | Correct list comprehension. | Python |
for count in range(58)
print(count) | for count in range(58):
print(count) | Colon after for. | Python |
switch(num){{ case 28: break; }} | switch(num){{ case 28: break; default: break; }} | Add default case. | Java |
h1 {{ font-size:88px color:#fff; }} | h1 {{ font-size:88px; color:#fff; }} | Add semicolon. | CSS |
arr.forEach(function(num) {{ console.log(num); }}) | arr.forEach((num) => {{ console.log(num); }}) | Arrow functions are cleaner. | JavaScript |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
for (int i=0; i<82; i++) {{}} | for (int i=0; i<82; i++) {{}} | Correct. | Java |
var x = 96; | var x = 96; | Correct. | Dart |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.