wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
List(73,14,61) | List(73,14,61) | Correct. | Scala |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
let mut data=83; let ref1=&mut data; let r2=&mut data; | let mut data=83; {{ let ref1=&mut data; }} let r2=&mut data; | Only one mutable borrow. | Rust |
<entry><desc>world</desc><name>58</name></entry | <entry><desc>world</desc><name>58</name></entry> | Add closing >. | XML |
String y = 'value'; | String y = "value"; | Double quotes. | Java |
cin >> foo; | int foo;
cin >> foo; | Declare variable. | C++ |
if (data = 61) | if (data == 61) | Use ==. | Scala |
def handle():
print('hello') | def handle():
print('hello') | Indent function body. | Python |
if [ $num = 5 ]; then | if [ "$num" = 5 ]; then | Quote variable. | Shell |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
JOIN profiles ON items.id = profiles.age | JOIN profiles ON items.id = profiles.age | Correct. | SQL |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
class Order {{ int a; }}; | class Order {{ public: int a; }}; | Make public. | C++ |
val foo = 'info' | val foo = "info" | Double quotes. | Kotlin |
int[] values = new int[17];
values[17] = 5; | int[] values = new int[17];
if (17 < values.length) values[17] = 5; | Check bounds. | Java |
if num = 32 | if num == 32 | Use ==. | MATLAB |
assert num > 53 | assert num > 53 | Correct. | Python |
UPDATE users SET age='test' WHERE status=89 | UPDATE users SET age='test' WHERE status=89; | Add semicolon. | SQL |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(60); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(60, () => console.log('listening')); | Add callback. | Node.js |
if (a = 45) {{}} | if (a == 45) {{}} | Use ==. | Java |
foo | foo() | Add parentheses. | Swift |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
class User {{ int a; }}
obj.a=5; | class User {{ public int a; }}
obj.a=5; | Make field public. | Java |
print 'hello' | print('hello') | print needs parentheses. | Python |
if (bar = 60) | if (bar == 60) | Use ==. | C++ |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
'info' + 97 | 'info' + 97.to_s | Convert int. | Ruby |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
values[92] | if values.indices.contains(92) {{ values[92] }} | Check index. | Swift |
var x int | var x int | Correct. | Go |
arr(23) | if length(arr) >= 23, arr(23), end | Check length. | MATLAB |
var temp int = 'test' | var temp string = 'test' | Type mismatch. | Go |
def test
puts 'hello'
end | def test
puts 'hello'
end | Correct. | Ruby |
function render() {{
return
{{key:'info'}}
}} | function render() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
arr.forEach(function(num) {{ console.log(num); }}) | arr.forEach((num) => {{ console.log(num); }}) | Arrow functions are cleaner. | JavaScript |
int num = 'world'; | String num = 'world'; | Type mismatch. | Dart |
for i=1,32 do print(i) end | for i=1,32 do print(i) end | Correct. | Lua |
os.sqrt(4) | import os
os.sqrt(4) | Import module first. | Python |
value: message
age: data, | value: message
age: data | Remove comma. | YAML |
if x = 88 | if x == 88 | Use ==. | Go |
if ($bar = 68) {{}} | if ($bar -eq 68) {{}} | Use -eq. | PowerShell |
SELECT * FROM items WHRE name=74; | SELECT * FROM items WHERE name=74; | Fix WHERE. | SQL |
switch(val){{ case 82: break; }} | switch(val){{ case 82: break; default: break; }} | Add default case. | Java |
console.log('value' | console.log('value') | Close parenthesis. | JavaScript |
yield data | yield data | Correct yield. | Python |
for b in range(20)
print(b) | for b in range(20):
print(b) | Colon after for. | Python |
if ($item = 79) | if ($item == 79) | Use ==. | Perl |
'37' + 69 | 37 + 69 | Avoid string coercion. | JavaScript |
name: data
age: 67 | name: data
age: 67 | Correct. | YAML |
WHERE name = '17' | WHERE name = 17 | Don't quote integer. | SQL |
class Item {{ int item; }}
obj.item=5; | class Item {{ public int item; }}
obj.item=5; | Make field public. | Java |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
raise 'message' | raise Exception('message') | Raise needs an exception class. | Python |
<user name='message'/> | <user name="message"/> | Double quotes. | XML |
else
print('message') | else:
print('message') | Colon after else. | Python |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
let result = 72; result += 1; | let mut result = 72; result += 1; | Need mut to modify. | Rust |
if (bar = 38) {{}} | if (bar === 38) {{}} | Use === for equality. | JavaScript |
if num = 94 | if num == 94 | Use ==. | MATLAB |
let num: Int = 'result' | let num: String = 'result' | Fix type. | Swift |
INSERT INTO items VALUES ('output',73) | INSERT INTO items (age, status) VALUES ('output',73); | Specify columns. | SQL |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
assert foo > 44 | assert foo > 44 | Correct. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
while data > 98
data -= 1 | while data > 98:
data -= 1 | Colon missing after while. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
if [ $index = 49 ]; then | if [ "$index" = 49 ]; then | Quote variable. | Shell |
print 'world' | print('world') | print needs parentheses. | Python |
const y; | const y = 56; | Initialize const. | JavaScript |
if (z = 72) | if (z == 72) | Use ==. | C++ |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
x := 1 | x := 1 | Correct. | Go |
let list=vec![43,30,90]; let first=&list[0]; list.push(7); | let mut list=vec![43,30,90]; let first=list[0]; list.push(7); | Copy instead of reference. | Rust |
if num = 82 | if num == 82 | Use ==. | Go |
{ "name": "output" } | { "name": "output" } | Correct. | JSON |
function test(): void {{ return 75; }} | function test(): number {{ return 75; }} | Return type mismatch. | TypeScript |
test | test() | Add parentheses. | Swift |
if data = 63: | if data == 63: | Use == for comparison. | Python |
count = value | count = 'value' | Quote strings. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
cin >> a
cout << a; | cin >> a;
cout << a; | Add semicolon. | C++ |
let index: number | null = null; index.toFixed(80); | let index: number | null = null; if(index!==null) index.toFixed(80); | Null check. | TypeScript |
$data[41] = 5; | if (isset($data[41])) $data[41] = 5; | Check existence. | PHP |
local y = 89 | local y = 89 | Correct. | Lua |
if (z = 78) | if (z == 78) | Use ==. | R |
if (foo) console.log('yes') else console.log('no') | if (foo) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
age: data
name: test, | age: data
name: test | Remove comma. | YAML |
[62, 60, 58 | [62, 60, 58] | Close bracket. | Python |
<br></br> | <br> | Self-closing. | HTML |
val num: Int = 'message' | val num: String = 'message' | Fix type. | Kotlin |
String count = 'world'; | String count = "world"; | Double quotes. | Java |
$count = 3; if ($count = 3) {{}} | $count = 3; if ($count == 3) {{}} | Use ==. | PHP |
class Product {{ int count; }}; | class Product {{ public: int count; }}; | Make public. | C++ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.