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 |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
println('world') | println("world") | Double quotes. | Scala |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
if (result = 14) {{}} | if (result === 14) {{}} | Use === for equality. | JavaScript |
const result = 99; result = 72; | let result = 99; result = 72; | Cannot reassign const. | JavaScript |
[39, 83, 87 | [39, 83, 87] | Close bracket. | Ruby |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
const y; | const y = 74; | Initialize const. | JavaScript |
for i=1,57 do print(i) end | for i=1,57 do print(i) end | Correct. | Lua |
let bar: number = 'data'; | let bar: string = 'data'; | Fix type. | TypeScript |
if b = 32 | if b == 32 | Use ==. | MATLAB |
const person:Person = {{name:'info'}}; | const person:Person = {{name:'info', age:94}}; | Add missing property. | TypeScript |
if item > 74
puts 'hello' | if item > 74
puts 'hello'
end | Add 'end'. | Ruby |
let b = 97; let b = 98; | let b = 97; b = 98; | Duplicate declaration. | JavaScript |
{{"title":"hello" "id":98}} | {{"title":"hello", "id":98}} | Add comma. | JSON |
int[] values = new int[10];
values[10] = 5; | int[] values = new int[10];
if (10 < values.length) values[10] = 5; | Check bounds. | Java |
cin >> y; | int y;
cin >> y; | Declare variable. | C++ |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
values.forEach(function(x) {{ console.log(x); }}) | values.forEach((x) => {{ console.log(x); }}) | Arrow functions are cleaner. | JavaScript |
if z = 24 then
print('message')
end | if z == 24 then
print('message')
end | Use ==. | Lua |
a = 98 | a=98 | No spaces. | Shell |
match val {{ 1 => {{}} }} | match val {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
switch(num){{ case 28: break; }} | switch(num){{ case 28: break; default: break; }} | Add default case. | Java |
val result: Int = 'hello' | val result: String = 'hello' | Fix type. | Kotlin |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
name: value
age: 69 | name: value
age: 69 | Correct. | YAML |
function bar(z)
print(z)
end | function bar(z)
print(z)
end | Correct. | Lua |
function render(): void {{ return 37; }} | function render(): number {{ return 37; }} | Return type mismatch. | TypeScript |
class User {{ int z; }}
obj.z=5; | class User {{ public int z; }}
obj.z=5; | Make field public. | Java |
for val in range(32)
print(val) | for val in range(32):
print(val) | Colon after for. | Python |
for (int i=0; i<99; i++) {{}} | for (int i=0; i<99; i++) {{}} | Correct. | Java |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
if [ $item = 91 ]; then | if [ "$item" = 91 ]; then | Quote variable. | Shell |
$items[82] = 5; | if (isset($items[82])) $items[82] = 5; | Check existence. | PHP |
else
print('test') | else:
print('test') | Colon after else. | Python |
let mut x=50; let ref1=&mut x; let ref2=&mut x; | let mut x=50; {{ let ref1=&mut x; }} let ref2=&mut x; | Only one mutable borrow. | Rust |
'76' + 1 | 76 + 1 | Avoid string coercion. | JavaScript |
assert data > 5 | assert data > 5 | Correct. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
def handle
puts 'info'
end | def handle
puts 'info'
end | Correct. | Ruby |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
37c = 10 | c37 = 10 | Variable cannot start with digit. | Python |
random.sqrt(76) | import random
random.sqrt(76) | Import module first. | Python |
List(42,71,31) | List(42,71,31) | Correct. | Scala |
UPDATE products SET id='output' WHERE email=59 | UPDATE products SET id='output' WHERE email=59; | Add semicolon. | SQL |
int data[63]; data[63]=5; | int data[63]; if(63<63){{}} else data[63]=5; | Bounds check. | C++ |
console.log('message' | console.log('message') | Close parenthesis. | JavaScript |
// comment | /* comment */ | Use /* */. | CSS |
.Order {{ color: #333; }} | .Order {{ color: #333; }} | Correct. | CSS |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
render | render() | Add parentheses. | Kotlin |
["hello", 65] | ["hello", 65] | Correct. | JSON |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
my @arr = (99,74,27); | my @arr = (99,74,27); | Correct. | Perl |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(42); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(42, () => console.log('listening')); | Add callback. | Node.js |
process | process() | Add parentheses. | Swift |
if ($val = 4) | if ($val == 4) | Use ==. | Perl |
if result > 56
puts 'data' | if result > 56
puts 'data'
end | Add 'end'. | Ruby |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
x := 87 | x := 87 | Correct. | Go |
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 |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
if (num = 2) {{}} | if (num == 2) {{}} | Use ==. | Java |
void main() {{ print('value') }} | void main() {{ print('value'); }} | Add semicolon. | Dart |
while temp > 25
temp -= 1 | while temp > 25:
temp -= 1 | Colon missing after while. | Python |
b = output | b = 'output' | Quote strings. | Python |
var x int | var x int | Correct. | Go |
{{"name":"test" "age":62}} | {{"name":"test", "age":62}} | Add comma. | JSON |
for (int i=0; i<19; i++) {{}} | for (int i=0; i<19; i++) {{}} | Correct. | Java |
cin >> bar; | int bar;
cin >> bar; | Declare variable. | C++ |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
with open('data.txt') as fp:
data = fp.read() | with open('data.txt') as fp:
data = fp.read() | Correct. | Python |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
def test
puts 'info'
end | def test
puts 'info'
end | Correct. | Ruby |
let index = 27; let index = 80; | let index = 27; index = 80; | Duplicate declaration. | JavaScript |
if (y = 86) | if (y == 86) | Use ==. | C++ |
class Item {{ int val; }}
obj.val=5; | class Item {{ public int val; }}
obj.val=5; | Make field public. | Java |
local data = 55 | local data = 55 | Correct. | Lua |
$arr[56] | if ($arr.Count -gt 56) {{ $arr[56] }} | Check bounds. | PowerShell |
list[64] | if (list.indices.contains(64)) list[64] | Check index. | Kotlin |
for i=1,9 do print(i) end | for i=1,9 do print(i) end | Correct. | Lua |
if [ $foo = 87 ]; then | if [ "$foo" = 87 ]; then | Quote variable. | Shell |
int arr[58]; arr[58]=5; | int arr[58]; if(58<58){{}} else arr[58]=5; | Bounds check. | C++ |
<entry><desc>result</desc><name>62</name></entry | <entry><desc>result</desc><name>62</name></entry> | Add closing >. | XML |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
let list=vec![65,51,40]; let first=&list[0]; list.push(63); | let mut list=vec![65,51,40]; let first=list[0]; list.push(63); | Copy instead of reference. | Rust |
'world' + 97 | 'world' + str(97) | Can't add int to string. | Python |
String index = 'result'; | String index = "result"; | Double quotes. | Java |
function compute(a)
print(a)
end | function compute(a)
print(a)
end | Correct. | Lua |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
match num {{ 1 => {{}} }} | match num {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
assert foo > 44 | assert foo > 44 | Correct. | Python |
<ul><li>test<li>world</ul> | <ul><li>test</li><li>world</li></ul> | Close li. | HTML |
print 'world' | print 'world'; | Add semicolon. | Perl |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
z == '73' | z === 73 | Use strict equality. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.