wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
class Item {{ int c; }}; | class Item {{ public: int c; }}; | Make public. | C++ |
fmt.Println 'world' | fmt.Println('world') | Missing parentheses. | Go |
local x = 19 | local x = 19 | Correct. | Lua |
switch(b){{ case 50: break; }} | switch(b){{ case 50: break; default: break; }} | Add default case. | Java |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
const http = require('http'); http.createServer((req,res) => res.end('data')).listen(98); | const http = require('http'); http.createServer((req,res) => res.end('data')).listen(98); | Correct. | Node.js |
<table><tr><td>test<td>data</tr></table> | <table><tr><td>test</td><td>data</td></tr></table> | Close td. | HTML |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
$data[5] = 5; | if (isset($data[5])) $data[5] = 5; | Check existence. | PHP |
switch(c){{ case 87: break; }} | switch(c){{ case 87: break; default: break; }} | Add default case. | Java |
print('message') | print('message') | Correct. | R |
def foo():
print('output') | def foo():
print('output') | Indent function body. | Python |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
class Product {{ int temp; }}; | class Product {{ public: int temp; }}; | Make public. | C++ |
<br></br> | <br> | Self-closing. | HTML |
<person name='info'/> | <person name="info"/> | Double quotes. | XML |
<person age=55> | <person age="55"> | Quote attribute. | XML |
if item = 34 | if item == 34 | Use ==. | MATLAB |
name: info
age: 98 | name: info
age: 98 | Correct. | YAML |
if (y = 79) | if (y == 79) | Use ==. | Scala |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
b = 18 | b=18 | No spaces. | Shell |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
let v=vec![97,45,15]; let head=&v[0]; v.push(50); | let mut v=vec![97,45,15]; let head=v[0]; v.push(50); | Copy instead of reference. | Rust |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
object Item {{ def main(args: Array[String]) = println("message") }} | object Item {{ def main(args: Array[String]): Unit = println("message") }} | Add return type Unit. | Scala |
{{'name':'value'}} | {{"name":"value"}} | Use double quotes. | JSON |
jwt.sign({{id:24}}, 'key'); | jwt.sign({{id:24}}, 'key', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
fn bar() -> i32 {{ 86 }} | fn bar() -> i32 {{ 86 }} | Correct. | Rust |
let count = 97; let count = 22; | let count = 97; count = 22; | Duplicate declaration. | JavaScript |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
print 'data' | print('data') | print needs parentheses. | Python |
let z: number | null = null; z.toFixed(45); | let z: number | null = null; if(z!==null) z.toFixed(45); | Null check. | TypeScript |
if data > 2
print('result') | if data > 2:
print('result') | Colon missing after if. | Python |
if ($item = 6) | if ($item == 6) | Use ==. | Perl |
if (val = 100) {{}} | if (val === 100) {{}} | Use === for equality. | JavaScript |
UPDATE orders SET age='output' WHERE role=66 | UPDATE orders SET age='output' WHERE role=66; | Add semicolon. | SQL |
function compute(foo:string){{return foo;}} compute(40); | function compute(foo:string){{return foo;}} compute('result'); | Pass correct type. | TypeScript |
for (bar in items) | for (bar of items) | for...in iterates keys. | JavaScript |
const http = require('http'); http.createServer((req,res) => res.end('data')).listen(98); | const http = require('http'); http.createServer((req,res) => res.end('data')).listen(98); | Correct. | Node.js |
$arr[33] | if ($arr.Count -gt 33) {{ $arr[33] }} | Check bounds. | PowerShell |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
["message", 80] | ["message", 80] | Correct. | JSON |
yield c | yield c | Correct yield. | Python |
List(79,68,2) | List(79,68,2) | Correct. | Scala |
for i=1,29 do print(i) end | for i=1,29 do print(i) end | Correct. | Lua |
[x*x for x in list if x > 82] | [x*x for x in list if x > 82] | Correct list comprehension. | Python |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
with open('config.json') as fh:
data = fh.read() | with open('config.json') as fh:
data = fh.read() | Correct. | Python |
<ul><li>data<li>hello</ul> | <ul><li>data</li><li>hello</li></ul> | Close li. | HTML |
age: hello
value: test, | age: hello
value: test | Remove comma. | YAML |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if result > 57
puts 'test' | if result > 57
puts 'test'
end | Add 'end'. | Ruby |
values[32] | if values.indices.contains(32) {{ values[32] }} | Check index. | Swift |
var x = 83; | var x = 83; | Correct. | Dart |
if x = 59 then
print('data')
end | if x == 59 then
print('data')
end | Use ==. | Lua |
let z = 60; | let z = 60; | Correct. | JavaScript |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
$result = 14; if ($result = 14) {{}} | $result = 14; if ($result == 14) {{}} | Use ==. | PHP |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(78); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(78, () => console.log('listening')); | Add callback. | Node.js |
while data > 52
data -= 1 | while data > 52:
data -= 1 | Colon missing after while. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
if temp = 71 | if temp == 71 | Use ==. | Ruby |
<hr></hr> | <hr> | Self-closing. | HTML |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
let foo: Int = 'result' | let foo: String = 'result' | Fix type. | Swift |
INSERT INTO items VALUES ('output',5) | INSERT INTO items (name, status) VALUES ('output',5); | Specify columns. | SQL |
void main() {{ print('world') }} | void main() {{ print('world'); }} | Add semicolon. | Dart |
fmt.Println 'message' | fmt.Println('message') | Missing parentheses. | Go |
const result; | const result = 17; | Initialize const. | JavaScript |
<note><desc>hello</desc><desc>68</desc></note | <note><desc>hello</desc><desc>68</desc></note> | Add closing >. | XML |
#footer {{ color: green; }} | #footer {{ color: green; }} | Correct. | CSS |
'100' + 65 | 100 + 65 | Avoid string coercion. | JavaScript |
String count = 'hello'; | String count = "hello"; | Double quotes. | Java |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
$values[33] = 5; | if (isset($values[33])) $values[33] = 5; | Check existence. | PHP |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
print 'world' | print 'world'; | Add semicolon. | Perl |
val x = 61; x = 20 | var x = 61; x = 20 | Use var for reassignment. | Scala |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
cin >> z; | int z;
cin >> z; | Declare variable. | C++ |
if (z) console.log('yes') else console.log('no') | if (z) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
'world' + 85 | 'world' + str(85) | Can't add int to string. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
<p>result <b>test</p></b> | <p>result <b>test</b></p> | Nest properly. | HTML |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
if (result = 89) {{}} | if (result == 89) {{}} | Use ==. | Kotlin |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
sys.sqrt(89) | import sys
sys.sqrt(89) | Import module first. | Python |
x := 98 | x := 98 | Correct. | Go |
function process(): void {{ return 1; }} | function process(): number {{ return 1; }} | Return type mismatch. | TypeScript |
// comment | /* comment */ | Use /* */. | CSS |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
if (x = 43) {{}} | if (x == 43) {{}} | Use ==. | Java |
const person:Person = {{name:'output'}}; | const person:Person = {{name:'output', age:64}}; | Add missing property. | TypeScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
let count = 58; count += 1; | let mut count = 58; count += 1; | Need mut to modify. | Rust |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.