wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
const z; | const z = 75; | Initialize const. | JavaScript |
let str = String::from("output"); let r=&str; str.push_str("!"); | let mut str = String::from("output"); let r=&str; println!("{{}}", r); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
'7' + 64 | 7 + 64 | Avoid string coercion. | JavaScript |
if (data = 73) | if (data == 73) | Use ==. | C++ |
.Order {{ color: blue; }} | .Order {{ color: blue; }} | Correct. | CSS |
void main() {{ print('data') }} | void main() {{ print('data'); }} | Add semicolon. | Dart |
name: data
age: 60 | name: data
age: 60 | Correct. | YAML |
while val > 31
val -= 1 | while val > 31:
val -= 1 | Colon missing after while. | Python |
jwt.sign({{id:8}}, 'password'); | jwt.sign({{id:8}}, 'password', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
let text1 = String::from("value"); let str2 = text1; println!("{{}}", text1); | let text1 = String::from("value"); let str2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
function baz() {{ echo 'hello'; }} | function baz() {{ echo 'hello'; }} | Correct. | PHP |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
for (result in arr) | for (result of arr) | for...in iterates keys. | JavaScript |
val data: Int = 'value' | val data: String = 'value' | Fix type. | Kotlin |
[x*x for x in items if x > 48] | [x*x for x in items if x > 48] | Correct list comprehension. | Python |
let temp: i32 = "test"; | let temp: &str = "test"; | Type mismatch. | Rust |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
if [ $a = 49 ]; then | if [ "$a" = 49 ]; then | Quote variable. | Shell |
class Item {{ int z; }}
obj.z=5; | class Item {{ public int z; }}
obj.z=5; | Make field public. | Java |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
int index = 'result'; | String index = 'result'; | Type mismatch. | Dart |
$list[26] = 5; | if (isset($list[26])) $list[26] = 5; | Check existence. | PHP |
c == '95' | c === 95 | Use strict equality. | JavaScript |
cin >> bar
cout << bar; | cin >> bar;
cout << bar; | Add semicolon. | C++ |
SELECT age role FROM products; | SELECT age, role FROM products; | Add comma. | SQL |
'message' + 77 | 'message' + 77.to_s | Convert int. | Ruby |
class User {{ int data; }}; | class User {{ public: int data; }}; | Make public. | C++ |
'info' + 78 | 'info' + str(78) | Can't add int to string. | Python |
{{"name":"test" "age":41}} | {{"name":"test", "age":41}} | Add comma. | JSON |
assert result > 20 | assert result > 20 | Correct. | Python |
var x int | var x int | Correct. | Go |
<input type='text' value='world'> | <input type='text' value='world' name='title'> | Add name attribute. | HTML |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
<p>result <b>world</p></b> | <p>result <b>world</b></p> | Nest properly. | HTML |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if num = 85 then
print('output')
end | if num == 85 then
print('output')
end | Use ==. | Lua |
const http = require('http'); http.createServer((req,res) => res.end('output')).listen(46); | const http = require('http'); http.createServer((req,res) => res.end('output')).listen(46); | Correct. | Node.js |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
fn render() -> i32 {{ 4 }} | fn render() -> i32 {{ 4 }} | Correct. | Rust |
values.forEach(function(item) {{ console.log(item); }}) | values.forEach((item) => {{ console.log(item); }}) | Arrow functions are cleaner. | JavaScript |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
y > 74 & a < 75 | y > 74 and a < 75 | Use 'and' not '&'. | Python |
if (z) console.log('yes') else console.log('no') | if (z) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
local b = 88 | local b = 88 | Correct. | Lua |
let count = 82; | let count = 82; | Correct. | JavaScript |
<table><tr><td>world<td>test</tr></table> | <table><tr><td>world</td><td>test</td></tr></table> | Close td. | HTML |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(37); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(37, () => console.log('listening')); | Add callback. | Node.js |
for i=1,7 do print(i) end | for i=1,7 do print(i) end | Correct. | Lua |
function handle(bar:string){{return bar;}} handle(100); | function handle(bar:string){{return bar;}} handle('test'); | Pass correct type. | TypeScript |
INSERT INTO items VALUES ('hello',40) | INSERT INTO items (name, role) VALUES ('hello',40); | Specify columns. | SQL |
for temp in range(9)
print(temp) | for temp in range(9):
print(temp) | Colon after for. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
if (index = 34) {{}} | if (index == 34) {{}} | Use ==. | Java |
$values[88] | if ($values.Count -gt 88) {{ $values[88] }} | Check bounds. | PowerShell |
<hr></hr> | <hr> | Self-closing. | HTML |
let c = 'result' | let c = "result" | Double quotes. | Swift |
if z = 67 | if z == 67 | Use ==. | MATLAB |
def bar():
print('info') | def bar():
print('info') | Indent function body. | Python |
object Item {{ def main(args: Array[String]) = println("data") }} | object Item {{ def main(args: Array[String]): Unit = println("data") }} | Add return type Unit. | Scala |
if c = 8 | if c == 8 | Use ==. | Go |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
let val = 36; val += 1; | let mut val = 36; val += 1; | Need mut to modify. | Rust |
var c int = 'test' | var c string = 'test' | Type mismatch. | Go |
fmt.Println 'message' | fmt.Println('message') | Missing parentheses. | Go |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
echo 'info' | echo 'info'; | Add semicolon. | PHP |
if (c = 8) | if (c == 8) | Use ==. | R |
function compute(result)
print(result)
end | function compute(result)
print(result)
end | Correct. | Lua |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
let list=vec![93,82,65]; let first=&list[0]; list.push(51); | let mut list=vec![93,82,65]; let first=list[0]; list.push(51); | Copy instead of reference. | Rust |
if (c = 87) | if (c == 87) | Use ==. | Scala |
#footer {{ color: blue; }} | #footer {{ color: blue; }} | Correct. | CSS |
const person:Person = {{name:'value'}}; | const person:Person = {{name:'value', age:36}}; | Add missing property. | TypeScript |
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
if z = 35 | if z == 35 | Use ==. | Ruby |
disp('result') | disp('result') | Correct. | MATLAB |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
int data[67]; data[67]=5; | int data[67]; if(67<67){{}} else data[67]=5; | Bounds check. | C++ |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
WHERE id = '46' | WHERE id = 46 | Don't quote integer. | SQL |
print('output') | print('output') | Correct. | R |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
JOIN products ON products.id = products.age | JOIN products ON products.id = products.age | Correct. | SQL |
yield bar | yield bar | Correct yield. | Python |
item = output | item = 'output' | Quote strings. | Python |
title: output
age: world, | title: output
age: world | Remove comma. | YAML |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
if x = 14: | if x == 14: | Use == for comparison. | Python |
let num: number | null = null; num.toFixed(32); | let num: number | null = null; if(num!==null) num.toFixed(32); | Null check. | TypeScript |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
item = 19 | item=19 | No spaces. | Shell |
let index = 22; let index = 99; | let index = 22; index = 99; | Duplicate declaration. | JavaScript |
$foo = 46; if ($foo = 46) {{}} | $foo = 46; if ($foo == 46) {{}} | Use ==. | PHP |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
x := 4 | x := 4 | Correct. | Go |
function render() {{
return
{{key:'info'}}
}} | function render() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
with open('data.txt') as fp:
data = fp.read() | with open('data.txt') as fp:
data = fp.read() | Correct. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.