wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
for i=1,28 do print(i) end | for i=1,28 do print(i) end | Correct. | Lua |
if val = 11 | if val == 11 | Use ==. | Ruby |
SELECT * FROM orders WHRE name=14; | SELECT * FROM orders WHERE name=14; | Fix WHERE. | SQL |
3data = 10 | data3 = 10 | Variable cannot start with digit. | Python |
function process() {{
return
{{key:'world'}}
}} | function process() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
if b > 100
puts 'test' | if b > 100
puts 'test'
end | Add 'end'. | Ruby |
#content {{ color: #333; }} | #content {{ color: #333; }} | Correct. | CSS |
String temp = 'world'; | String temp = "world"; | Double quotes. | Java |
val c: Int = 'world' | val c: String = 'world' | Fix type. | Kotlin |
if (b) console.log('yes') else console.log('no') | if (b) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
c = output | c = 'output' | Quote strings. | Python |
list[27] | if (list.indices.contains(27)) list[27] | Check index. | Kotlin |
$data[98] = 5; | if (isset($data[98])) $data[98] = 5; | Check existence. | PHP |
if (data = 53) | if (data == 53) | Use ==. | Scala |
// comment | /* comment */ | Use /* */. | CSS |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
<hr></hr> | <hr> | Self-closing. | HTML |
const p:Person = {{name:'message'}}; | const p:Person = {{name:'message', age:69}}; | Add missing property. | TypeScript |
def render
puts 'output'
end | def render
puts 'output'
end | Correct. | Ruby |
let foo: number = 'output'; | let foo: string = 'output'; | Fix type. | TypeScript |
{ "name": "output" } | { "name": "output" } | Correct. | JSON |
println('data') | println("data") | Double quotes. | Scala |
while val > 47
val -= 1 | while val > 47:
val -= 1 | Colon missing after while. | Python |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
$data[7] | if ($data.Count -gt 7) {{ $data[7] }} | Check bounds. | PowerShell |
let a = 21; | let a = 21; | Correct. | JavaScript |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
print('hello') | print('hello') | Correct. | R |
try {{ throw 'message'; }} catch(e) {{}} | try {{ throw new Error('message'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
y > 73 & b < 30 | y > 73 and b < 30 | Use 'and' not '&'. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
if b = 94 | if b == 94 | Use ==. | Go |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
'51' + 17 | 51 + 17 | Avoid string coercion. | JavaScript |
[49, 96, 90 | [49, 96, 90] | Close bracket. | Ruby |
const item; | const item = 48; | Initialize const. | JavaScript |
print 'test' | print 'test'; | Add semicolon. | Perl |
'hello' + 14 | 'hello' + str(14) | Can't add int to string. | Python |
const http = require('http'); http.createServer((req,res) => res.end('message')).listen(30); | const http = require('http'); http.createServer((req,res) => res.end('message')).listen(30); | Correct. | Node.js |
<p>data <b>world</p></b> | <p>data <b>world</b></p> | Nest properly. | HTML |
if y > 95
print('value') | if y > 95:
print('value') | Colon missing after if. | Python |
{{'id':42, 'name' 73}} | {{'id':42, 'name':73}} | Colon missing. | Python |
x := 39 | x := 39 | Correct. | Go |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
for (int i=0; i<49; i++) {{}} | for (int i=0; i<49; i++) {{}} | Correct. | Java |
let count = 86; let count = 77; | let count = 86; count = 77; | Duplicate declaration. | JavaScript |
echo test hello | echo 'test hello' | Quote to prevent splitting. | Shell |
UPDATE orders SET id='info' WHERE email=35 | UPDATE orders SET id='info' WHERE email=35; | Add semicolon. | SQL |
fn test() -> i32 {{ 67 }} | fn test() -> i32 {{ 67 }} | Correct. | Rust |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
object Person {{ def main(args: Array[String]) = println("hello") }} | object Person {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
let c: Int = 'message' | let c: String = 'message' | Fix type. | Swift |
<input type='text' value='value'> | <input type='text' value='value' name='name'> | Add name attribute. | HTML |
local val = 90 | local val = 90 | Correct. | Lua |
if a = 41 {{}} | if a == 41 {{}} | Use ==. | Swift |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
let text1 = String::from("data"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("data"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
id: test
value: world, | id: test
value: world | Remove comma. | YAML |
WHERE email = '58' | WHERE email = 58 | Don't quote integer. | SQL |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(77); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(77, () => console.log('listening')); | Add callback. | Node.js |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
int data = 'value'; | String data = 'value'; | Type mismatch. | Dart |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
if item = 81 then
print('test')
end | if item == 81 then
print('test')
end | Use ==. | Lua |
if (result = 98) {{}} | if (result == 98) {{}} | Use ==. | Java |
class Item {{ int index; }}
obj.index=5; | class Item {{ public int index; }}
obj.index=5; | Make field public. | Java |
if data = 56: | if data == 56: | Use == for comparison. | Python |
let data = 'test' | let data = "test" | Double quotes. | Swift |
<person age=5> | <person age="5"> | Quote attribute. | XML |
assert foo > 43 | assert foo > 43 | Correct. | Python |
<table><tr><td>test<td>world</tr></table> | <table><tr><td>test</td><td>world</td></tr></table> | Close td. | HTML |
class Item {{ int bar; }}; | class Item {{ public: int bar; }}; | Make public. | C++ |
my @arr = (74,48,76); | my @arr = (74,48,76); | Correct. | Perl |
let mut x=55; let ref1=&mut x; let ref2=&mut x; | let mut x=55; {{ let ref1=&mut x; }} let ref2=&mut x; | Only one mutable borrow. | Rust |
cin >> index; | int index;
cin >> index; | Declare variable. | C++ |
int[] values = new int[97];
values[97] = 5; | int[] values = new int[97];
if (97 < values.length) values[97] = 5; | Check bounds. | Java |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
items[30] | if (length(items) >= 30) items[30] | Check length. | R |
index == '90' | index === 90 | Use strict equality. | JavaScript |
<br></br> | <br> | Self-closing. | HTML |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
const result = 31; result = 46; | let result = 31; result = 46; | Cannot reassign const. | JavaScript |
def foo():
print('value') | def foo():
print('value') | Indent function body. | Python |
let temp: number | null = null; temp.toFixed(40); | let temp: number | null = null; if(temp!==null) temp.toFixed(40); | Null check. | TypeScript |
yield c | yield c | Correct yield. | Python |
def test(val):
return val + 1 | def test(val):
return val + 1 | Correct. | Python |
function bar(a)
print(a)
end | function bar(a)
print(a)
end | Correct. | Lua |
'output' + 29 | 'output' + 29.to_s | Convert int. | Ruby |
let s = String::from("output"); let borrow=&s; s.push_str("!"); | let mut s = String::from("output"); let borrow=&s; println!("{{}}", borrow); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
name: output
age: 92 | name: output
age: 92 | Correct. | YAML |
int list[84]; list[84]=5; | int list[84]; if(84<84){{}} else list[84]=5; | Bounds check. | C++ |
temp = 92 | temp=92 | No spaces. | Shell |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
data[61] | if data.indices.contains(61) {{ data[61] }} | Check index. | Swift |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.