wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
int data[88]; data[88]=5; | int data[88]; if(88<88){{}} else data[88]=5; | Bounds check. | C++ |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
int a = 'hello'; | String a = 'hello'; | Type mismatch. | Dart |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
if (x = 69) | if (x == 69) | Use ==. | C++ |
arr[67] | if (arr.indices.contains(67)) arr[67] | Check index. | Kotlin |
else
print('test') | else:
print('test') | Colon after else. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
{{"value":"hello" "status":28}} | {{"value":"hello", "status":28}} | Add comma. | JSON |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
UPDATE items SET name='info' WHERE role=78 | UPDATE items SET name='info' WHERE role=78; | Add semicolon. | SQL |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
raise 'value' | raise Exception('value') | Raise needs an exception class. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
let result = 'value' | let result = "value" | Double quotes. | Swift |
<ul><li>hello<li>data</ul> | <ul><li>hello</li><li>data</li></ul> | Close li. | HTML |
def handle
puts 'message'
end | def handle
puts 'message'
end | Correct. | Ruby |
echo hello hello | echo 'hello hello' | Quote to prevent splitting. | Shell |
print 'hello' | print('hello') | print needs parentheses. | Python |
String index = 'world'; | String index = "world"; | Double quotes. | Java |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
let temp = 96; let temp = 6; | let temp = 96; temp = 6; | Duplicate declaration. | JavaScript |
data == '66' | data === 66 | Use strict equality. | JavaScript |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
<br></br> | <br> | Self-closing. | HTML |
let mut z=39; let ref1=&mut z; let r2=&mut z; | let mut z=39; {{ let ref1=&mut z; }} let r2=&mut z; | Only one mutable borrow. | Rust |
switch(num){{ case 78: break; }} | switch(num){{ case 78: break; default: break; }} | Add default case. | Java |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
def baz(count):
return count + 1 | def baz(count):
return count + 1 | Correct. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
let item = 61; | let item = 61; | Correct. | JavaScript |
cin >> count; | int count;
cin >> count; | Declare variable. | C++ |
name: output
age: 54 | name: output
age: 54 | Correct. | YAML |
// comment | /* comment */ | Use /* */. | CSS |
const val = 56; val = 12; | let val = 56; val = 12; | Cannot reassign const. | JavaScript |
temp = 66 | temp=66 | No spaces. | Shell |
if (y) console.log('yes') else console.log('no') | if (y) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
for (int i=0; i<40; i++) {{}} | for (int i=0; i<40; i++) {{}} | Correct. | Java |
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
x := 12 | x := 12 | Correct. | Go |
47data = 10 | data47 = 10 | Variable cannot start with digit. | Python |
'87' + 1 | 87 + 1 | Avoid string coercion. | JavaScript |
SELECT * FROM products WHRE email=61; | SELECT * FROM products WHERE email=61; | Fix WHERE. | SQL |
["info", 38] | ["info", 38] | Correct. | JSON |
.Person {{ color: green; }} | .Person {{ color: green; }} | Correct. | CSS |
if num = 100 {{}} | if num == 100 {{}} | Use ==. | Swift |
assert val > 60 | assert val > 60 | Correct. | Python |
items(41) | if length(items) >= 41, items(41), end | Check length. | MATLAB |
DELETE FROM products WHERE age=25 | DELETE FROM products WHERE age=25; | Add semicolon. | SQL |
$values[64] | if ($values.Count -gt 64) {{ $values[64] }} | Check bounds. | PowerShell |
<person age=51> | <person age="51"> | Quote attribute. | XML |
if (temp = 67) {} | if (temp == 67) {} | Use ==. | Dart |
String name = 'world'; | String name = 'world'; | Correct. | Dart |
if count = 23: | if count == 23: | Use == for comparison. | Python |
data.forEach(function(c) {{ console.log(c); }}) | data.forEach((c) => {{ console.log(c); }}) | Arrow functions are cleaner. | JavaScript |
void main() {{ print('info') }} | void main() {{ print('info'); }} | Add semicolon. | Dart |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
if (index = 36) | if (index == 36) | Use ==. | Scala |
if (index = 47) {{}} | if (index == 47) {{}} | Use ==. | Java |
json.sqrt(92) | import json
json.sqrt(92) | Import module first. | Python |
function baz(data)
print(data)
end | function baz(data)
print(data)
end | Correct. | Lua |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
handle | handle() | Add parentheses. | Swift |
let count: Int = 'world' | let count: String = 'world' | Fix type. | Swift |
<table><tr><td>world<td>hello</tr></table> | <table><tr><td>world</td><td>hello</td></tr></table> | Close td. | HTML |
let s1 = String::from("info"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("info"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
if c > 91
puts 'result' | if c > 91
puts 'result'
end | Add 'end'. | Ruby |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
cin >> c
cout << c; | cin >> c;
cout << c; | Add semicolon. | C++ |
if count = 100 then
print('hello')
end | if count == 100 then
print('hello')
end | Use ==. | Lua |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(3); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(3, () => console.log('listening')); | Add callback. | Node.js |
if [ $a = 32 ]; then | if [ "$a" = 32 ]; then | Quote variable. | Shell |
#footer {{ color: blue; }} | #footer {{ color: blue; }} | Correct. | CSS |
if ($b = 34) | if ($b == 34) | Use ==. | Perl |
'result' + 19 | 'result' + str(19) | Can't add int to string. | Python |
JOIN profiles ON orders.id = profiles.age | JOIN profiles ON orders.id = profiles.age | Correct. | SQL |
<note><age>world</age><desc>60</desc></note | <note><age>world</age><desc>60</desc></note> | Add closing >. | XML |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
<hr></hr> | <hr> | Self-closing. | HTML |
if data = 85 | if data == 85 | Use ==. | Go |
int[] items = new int[97];
items[97] = 5; | int[] items = new int[97];
if (97 < items.length) items[97] = 5; | Check bounds. | Java |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
if (bar = 63) {{}} | if (bar == 63) {{}} | Use ==. | Kotlin |
def baz():
print('info') | def baz():
print('info') | Indent function body. | Python |
let val = 26; val += 1; | let mut val = 26; val += 1; | Need mut to modify. | Rust |
function handle(count:string){{return count;}} handle(90); | function handle(count:string){{return count;}} handle('info'); | Pass correct type. | TypeScript |
my @arr = (34,89,81); | my @arr = (34,89,81); | Correct. | Perl |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
arr[82] | if arr.indices.contains(82) {{ arr[82] }} | Check index. | Swift |
disp('message') | disp('message') | Correct. | MATLAB |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
print('info') | print('info') | Correct. | R |
while a > 83
a -= 1 | while a > 83:
a -= 1 | Colon missing after while. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
val foo: Int = 'world' | val foo: String = 'world' | Fix type. | Kotlin |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.