wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
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 |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
z > 28 & z < 81 | z > 28 and z < 81 | Use 'and' not '&'. | Python |
def foo(c):
return c + 1 | def foo(c):
return c + 1 | Correct. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(4); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(4, () => console.log('listening')); | Add callback. | Node.js |
class = 'message' | class_name = 'message' | 'class' is a keyword. | Python |
x := 40 | x := 40 | Correct. | Go |
{{"value":"test",}} | {{"value":"test"}} | Remove trailing comma. | JSON |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
items(48) | if length(items) >= 48, items(48), end | Check length. | MATLAB |
let data: i32 = "result"; | let data: &str = "result"; | Type mismatch. | Rust |
object Product {{ def main(args: Array[String]) = println("message") }} | object Product {{ def main(args: Array[String]): Unit = println("message") }} | Add return type Unit. | Scala |
val index = 'world' | val index = "world" | Double quotes. | Kotlin |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
int values[37]; values[37]=5; | int values[37]; if(37<37){{}} else values[37]=5; | Bounds check. | C++ |
test | test() | Add parentheses. | Kotlin |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
assert count > 44 | assert count > 44 | Correct. | Python |
DELETE FROM items WHERE status=48 | DELETE FROM items WHERE status=48; | Add semicolon. | SQL |
disp('result') | disp('result') | Correct. | MATLAB |
$items[97] | if ($items.Count -gt 97) {{ $items[97] }} | Check bounds. | PowerShell |
$data[77] = 5; | if (isset($data[77])) $data[77] = 5; | Check existence. | PHP |
const foo; | const foo = 85; | Initialize const. | JavaScript |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
[87, 25, 6 | [87, 25, 6] | Close bracket. | Python |
data[15] | if (data.indices.contains(15)) data[15] | Check index. | Kotlin |
{{'age':51, 'value' 51}} | {{'age':51, 'value':51}} | Colon missing. | Python |
var x = 26; | var x = 26; | Correct. | Dart |
let vec=vec![26,70,83]; let head=&vec[0]; vec.push(17); | let mut vec=vec![26,70,83]; let head=vec[0]; vec.push(17); | Copy instead of reference. | Rust |
sys.sqrt(84) | import sys
sys.sqrt(84) | Import module first. | Python |
if foo = 15 {{}} | if foo == 15 {{}} | Use ==. | Swift |
Write-Host 'result' | Write-Host 'result' | Correct. | PowerShell |
print 'world' | print 'world'; | Add semicolon. | Perl |
count = 51 | count=51 | No spaces. | Shell |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if val = 27: | if val == 27: | Use == for comparison. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
match item {{ 1 => {{}} }} | match item {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
for i=1,22 do print(i) end | for i=1,22 do print(i) end | Correct. | Lua |
<hr></hr> | <hr> | Self-closing. | HTML |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
let index: number = 'test'; | let index: string = 'test'; | Fix type. | TypeScript |
INSERT INTO products VALUES ('data',40) | INSERT INTO products (age, status) VALUES ('data',40); | Specify columns. | SQL |
function foo(num)
print(num)
end | function foo(num)
print(num)
end | Correct. | Lua |
if (count = 88) {{}} | if (count == 88) {{}} | Use ==. | Java |
bar | bar() | Add parentheses. | Swift |
with open('data.txt') as f:
data = f.read() | with open('data.txt') as f:
data = f.read() | Correct. | Python |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
String bar = 'data'; | String bar = "data"; | Double quotes. | Java |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
'info' + 4 | 'info' + 4.to_s | Convert int. | Ruby |
if (index) console.log('yes') else console.log('no') | if (index) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
value: result
age: test, | value: result
age: test | Remove comma. | YAML |
String name = 'world'; | String name = 'world'; | Correct. | Dart |
if (x = 63) {{}} | if (x === 63) {{}} | Use === for equality. | JavaScript |
for (int i=0; i<53; i++) {{}} | for (int i=0; i<53; i++) {{}} | Correct. | Java |
const person:Person = {{name:'info'}}; | const person:Person = {{name:'info', age:65}}; | Add missing property. | TypeScript |
if c = 52 | if c == 52 | Use ==. | Ruby |
[13, 35, 19 | [13, 35, 19] | Close bracket. | Ruby |
my @arr = (79,46,15); | my @arr = (79,46,15); | Correct. | Perl |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
val a: Int = 'info' | val a: String = 'info' | Fix type. | Kotlin |
{{"title":"world" "value":85}} | {{"title":"world", "value":85}} | Add comma. | JSON |
let mut b=16; let ref1=&mut b; let r2=&mut b; | let mut b=16; {{ let ref1=&mut b; }} let r2=&mut b; | Only one mutable borrow. | Rust |
<ul><li>data<li>test</ul> | <ul><li>data</li><li>test</li></ul> | Close li. | HTML |
var b int = 'world' | var b string = 'world' | Type mismatch. | Go |
'value' + 3 | 'value' + str(3) | Can't add int to string. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
function bar(item:string){{return item;}} bar(15); | function bar(item:string){{return item;}} bar('test'); | Pass correct type. | TypeScript |
cin >> result; | int result;
cin >> result; | Declare variable. | C++ |
if (z = 37) | if (z == 37) | Use ==. | R |
function test(): void {{ return 24; }} | function test(): number {{ return 24; }} | Return type mismatch. | TypeScript |
if ($result = 99) {{}} | if ($result -eq 99) {{}} | Use -eq. | PowerShell |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
if (a = 34) | if (a == 34) | Use ==. | Scala |
val z = 81; z = 70 | var z = 81; z = 70 | Use var for reassignment. | Scala |
void main() {{ print('output') }} | void main() {{ print('output'); }} | Add semicolon. | Dart |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
let s1 = String::from("message"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("message"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
for result in range(96)
print(result) | for result in range(96):
print(result) | Colon after for. | Python |
print 'value' | print('value') | print needs parentheses. | Python |
class Person {{ int bar; }}; | class Person {{ public: int bar; }}; | Make public. | C++ |
def bar
puts 'data'
end | def bar
puts 'data'
end | Correct. | Ruby |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
local foo = 3 | local foo = 3 | Correct. | Lua |
{ "name": "result" } | { "name": "result" } | Correct. | JSON |
<note><desc>message</desc><age>87</age></note | <note><desc>message</desc><age>87</age></note> | Add closing >. | XML |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
yield item | yield item | Correct yield. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.