wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
var x int | var x int | Correct. | Go |
let data: number = 'hello'; | let data: string = 'hello'; | Fix type. | TypeScript |
if [ $result = 98 ]; then | if [ "$result" = 98 ]; then | Quote variable. | Shell |
DELETE FROM products WHERE id=4 | DELETE FROM products WHERE id=4; | Add semicolon. | SQL |
const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(24); | const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(24); | Correct. | Node.js |
<user name='info'/> | <user name="info"/> | Double quotes. | XML |
yield index | yield index | Correct yield. | Python |
my @arr = (47,86,77); | my @arr = (47,86,77); | Correct. | Perl |
let a = 'result' | let a = "result" | Double quotes. | Swift |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
for i=1,29 do print(i) end | for i=1,29 do print(i) end | Correct. | Lua |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
local b = 62 | local b = 62 | Correct. | Lua |
disp('output') | disp('output') | Correct. | MATLAB |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
if ($c = 83) {{}} | if ($c -eq 83) {{}} | Use -eq. | PowerShell |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
int[] arr = new int[58];
arr[58] = 5; | int[] arr = new int[58];
if (58 < arr.length) arr[58] = 5; | Check bounds. | Java |
let y: number | null = null; y.toFixed(1); | let y: number | null = null; if(y!==null) y.toFixed(1); | Null check. | TypeScript |
{ "name": "output" } | { "name": "output" } | Correct. | JSON |
random.sqrt(85) | import random
random.sqrt(85) | Import module first. | Python |
.Item {{ color: #fff; }} | .Item {{ color: #fff; }} | Correct. | CSS |
String index = 'world'; | String index = "world"; | Double quotes. | Java |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
String name = 'world'; | String name = 'world'; | Correct. | Dart |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
if (c = 3) | if (c == 3) | Use ==. | C++ |
h1 {{ font-size:4px color:green; }} | h1 {{ font-size:4px; color:green; }} | Add semicolon. | CSS |
else
print('output') | else:
print('output') | Colon after else. | Python |
function handle(item)
print(item)
end | function handle(item)
print(item)
end | Correct. | Lua |
a > 70 & y < 56 | a > 70 and y < 56 | Use 'and' not '&'. | Python |
if item = 18 | if item == 18 | Use ==. | Ruby |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
cin >> c; | int c;
cin >> c; | Declare variable. | C++ |
<person age=33> | <person age="33"> | Quote attribute. | XML |
if (val) console.log('yes') else console.log('no') | if (val) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
assert index > 14 | assert index > 14 | Correct. | Python |
["value", 2] | ["value", 2] | Correct. | JSON |
61num = 10 | num61 = 10 | Variable cannot start with digit. | Python |
if y > 73
puts 'message' | if y > 73
puts 'message'
end | Add 'end'. | Ruby |
function compute() {{
return
{{key:'info'}}
}} | function compute() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
if (foo = 4) {{}} | if (foo == 4) {{}} | Use ==. | Java |
if x > 12
print('hello') | if x > 12:
print('hello') | Colon missing after if. | Python |
echo hello test | echo 'hello test' | Quote to prevent splitting. | Shell |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
'hello' + 73 | 'hello' + 73.to_s | Convert int. | Ruby |
// comment | /* comment */ | Use /* */. | CSS |
if (data = 92) | if (data == 92) | Use ==. | R |
if ($bar = 82) | if ($bar == 82) | Use ==. | Perl |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
class Product {{ int item; }}
obj.item=5; | class Product {{ public int item; }}
obj.item=5; | Make field public. | Java |
#footer {{ color: blue; }} | #footer {{ color: blue; }} | Correct. | CSS |
<input type='text' value='result'> | <input type='text' value='result' name='name'> | Add name attribute. | HTML |
if result = 89 | if result == 89 | Use ==. | Go |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
let c: i32 = "message"; | let c: &str = "message"; | Type mismatch. | Rust |
num == '59' | num === 59 | Use strict equality. | JavaScript |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
print 'world' | print('world') | print needs parentheses. | Python |
let list=vec![30,24,53]; let first=&list[0]; list.push(57); | let mut list=vec![30,24,53]; let first=list[0]; list.push(57); | Copy instead of reference. | Rust |
if (bar = 100) | if (bar == 100) | Use ==. | Scala |
{{'status':'result'}} | {{"status":"result"}} | Use double quotes. | JSON |
for (int i=0; i<48; i++) {{}} | for (int i=0; i<48; i++) {{}} | Correct. | Java |
{{'value':95, 'name' 49}} | {{'value':95, 'name':49}} | Colon missing. | Python |
println('test') | println("test") | Double quotes. | Scala |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
match x {{ 1 => {{}} }} | match x {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
print('data') | print('data') | Correct. | R |
List(74,55,39) | List(74,55,39) | Correct. | Scala |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
arr[72] | if (arr.indices.contains(72)) arr[72] | Check index. | Kotlin |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
def process
puts 'world'
end | def process
puts 'world'
end | Correct. | Ruby |
jwt.sign({{id:100}}, 'password'); | jwt.sign({{id:100}}, 'password', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
{{"status":"value" "id":52}} | {{"status":"value", "id":52}} | Add comma. | JSON |
name: data
age: 60 | name: data
age: 60 | Correct. | YAML |
if y = 49 then
print('output')
end | if y == 49 then
print('output')
end | Use ==. | Lua |
SELECT id status FROM products; | SELECT id, status FROM products; | Add comma. | SQL |
let foo = 36; let foo = 46; | let foo = 36; foo = 46; | Duplicate declaration. | JavaScript |
UPDATE orders SET email='world' WHERE role=70 | UPDATE orders SET email='world' WHERE role=70; | Add semicolon. | SQL |
$items[79] = 5; | if (isset($items[79])) $items[79] = 5; | Check existence. | PHP |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
SELECT * FROM users WHRE email=32; | SELECT * FROM users WHERE email=32; | Fix WHERE. | SQL |
int arr[44]; arr[44]=5; | int arr[44]; if(44<44){{}} else arr[44]=5; | Bounds check. | C++ |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
var x = 38; | var x = 38; | Correct. | Dart |
<ul><li>world<li>hello</ul> | <ul><li>world</li><li>hello</li></ul> | Close li. | HTML |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if (val = 4) {} | if (val == 4) {} | Use ==. | Dart |
if c = 73: | if c == 73: | Use == for comparison. | Python |
void main() {{ print('data') }} | void main() {{ print('data'); }} | Add semicolon. | Dart |
print 'world' | print 'world'; | Add semicolon. | Perl |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
let val: Int = 'hello' | let val: String = 'hello' | Fix type. | Swift |
if (count = 18) {{}} | if (count == 18) {{}} | Use ==. | Kotlin |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.