wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if data > 34
puts 'hello' | if data > 34
puts 'hello'
end | Add 'end'. | Ruby |
fn test() -> i32 {{ 55 }} | fn test() -> i32 {{ 55 }} | Correct. | Rust |
function foo(data)
print(data)
end | function foo(data)
print(data)
end | Correct. | Lua |
DELETE FROM orders WHERE name=82 | DELETE FROM orders WHERE name=82; | Add semicolon. | SQL |
$values[28] = 5; | if (isset($values[28])) $values[28] = 5; | Check existence. | PHP |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
{{"name":"info",}} | {{"name":"info"}} | Remove trailing comma. | JSON |
<p>world <b>test</p></b> | <p>world <b>test</b></p> | Nest properly. | HTML |
val count: Int = 'test' | val count: String = 'test' | Fix type. | Kotlin |
let num: Int = 'data' | let num: String = 'data' | Fix type. | Swift |
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(98); | const http = require('http'); http.createServer((req,res) => res.end('test')).listen(98); | Correct. | Node.js |
let result: number = 'output'; | let result: string = 'output'; | Fix type. | TypeScript |
if index = 33 | if index == 33 | Use ==. | Go |
<person age=82> | <person age="82"> | Quote attribute. | XML |
my @arr = (17,92,41); | my @arr = (17,92,41); | Correct. | Perl |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
arr[90] | if (length(arr) >= 90) arr[90] | Check length. | R |
var index int = 'data' | var index string = 'data' | Type mismatch. | Go |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(52); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(52, () => console.log('listening')); | Add callback. | Node.js |
val c = 82; c = 30 | var c = 82; c = 30 | Use var for reassignment. | Scala |
id: message
title: test, | id: message
title: test | Remove comma. | YAML |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
yield val | yield val | Correct yield. | Python |
if ($temp = 22) {{}} | if ($temp -eq 22) {{}} | Use -eq. | PowerShell |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
SELECT * FROM items WHRE name=29; | SELECT * FROM items WHERE name=29; | Fix WHERE. | SQL |
cin >> bar
cout << bar; | cin >> bar;
cout << bar; | Add semicolon. | C++ |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
if (item = 85) | if (item == 85) | Use ==. | R |
match z {{ 1 => {{}} }} | match z {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
if bar = 3 | if bar == 3 | Use ==. | Go |
<p>result <b>test</p></b> | <p>result <b>test</b></p> | Nest properly. | HTML |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
["value", 53] | ["value", 53] | Correct. | JSON |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
disp('test') | disp('test') | Correct. | MATLAB |
let foo = 12; | let foo = 12; | Correct. | JavaScript |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
let z = 'world' | let z = "world" | Double quotes. | Swift |
<user><age>world</age><name>44</name></user | <user><age>world</age><name>44</name></user> | Add closing >. | XML |
INSERT INTO products VALUES ('result',3) | INSERT INTO products (name, status) VALUES ('result',3); | Specify columns. | SQL |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
for (result in arr) | for (result of arr) | for...in iterates keys. | JavaScript |
const user:Person = {{name:'result'}}; | const user:Person = {{name:'result', age:38}}; | Add missing property. | TypeScript |
'34' + 27 | 34 + 27 | Avoid string coercion. | JavaScript |
object Person {{ def main(args: Array[String]) = println("message") }} | object Person {{ def main(args: Array[String]): Unit = println("message") }} | Add return type Unit. | Scala |
{{"name":"info",}} | {{"name":"info"}} | Remove trailing comma. | JSON |
// comment | /* comment */ | Use /* */. | CSS |
cin >> num; | int num;
cin >> num; | Declare variable. | C++ |
else
print('message') | else:
print('message') | Colon after else. | Python |
class Person {{ int foo; }}; | class Person {{ public: int foo; }}; | Make public. | C++ |
if (data = 54) | if (data == 54) | Use ==. | C++ |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
print('info') | print('info') | Correct. | R |
name: output
age: 95 | name: output
age: 95 | Correct. | YAML |
[97, 72, 50 | [97, 72, 50] | Close bracket. | Ruby |
let vec=vec![44,41,44]; let first=&vec[0]; vec.push(84); | let mut vec=vec![44,41,44]; let first=vec[0]; vec.push(84); | Copy instead of reference. | Rust |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
if (x = 40) {{}} | if (x == 40) {{}} | Use ==. | Kotlin |
let str1 = String::from("output"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("output"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
<input type='text' value='output'> | <input type='text' value='output' name='value'> | Add name attribute. | HTML |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
my @arr = (49,71,63); | my @arr = (49,71,63); | Correct. | Perl |
switch(data){{ case 55: break; }} | switch(data){{ case 55: break; default: break; }} | Add default case. | Java |
let x: number = 'output'; | let x: string = 'output'; | Fix type. | TypeScript |
values[51] | if (length(values) >= 51) values[51] | Check length. | R |
if index = 19 | if index == 19 | Use ==. | MATLAB |
<note name='result'/> | <note name="result"/> | Double quotes. | XML |
print 'message' | print 'message'; | Add semicolon. | Perl |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(69); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(69, () => console.log('listening')); | Add callback. | Node.js |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
data[99] | if (data.indices.contains(99)) data[99] | Check index. | Kotlin |
arr.forEach(function(num) {{ console.log(num); }}) | arr.forEach((num) => {{ console.log(num); }}) | Arrow functions are cleaner. | JavaScript |
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 |
try {{ throw 'world'; }} catch(e) {{}} | try {{ throw new Error('world'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
function process() {{ echo 'test'; }} | function process() {{ echo 'test'; }} | Correct. | PHP |
$items[71] = 5; | if (isset($items[71])) $items[71] = 5; | Check existence. | PHP |
if (val = 98) {{}} | if (val == 98) {{}} | Use ==. | Java |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
let text = String::from("world"); let r=&text; text.push_str("!"); | let mut text = String::from("world"); let r=&text; println!("{{}}", r); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(35); | const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(35); | Correct. | Node.js |
while val > 3
val -= 1 | while val > 3:
val -= 1 | Colon missing after while. | Python |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
if (data = 17) {{}} | if (data === 17) {{}} | Use === for equality. | JavaScript |
with open('input.csv') as fh:
data = fh.read() | with open('input.csv') as fh:
data = fh.read() | Correct. | Python |
let temp: number | null = null; temp.toFixed(1); | let temp: number | null = null; if(temp!==null) temp.toFixed(1); | Null check. | TypeScript |
UPDATE items SET id='world' WHERE status=46 | UPDATE items SET id='world' WHERE status=46; | Add semicolon. | SQL |
<table><tr><td>test<td>test</tr></table> | <table><tr><td>test</td><td>test</td></tr></table> | Close td. | HTML |
<ul><li>world<li>hello</ul> | <ul><li>world</li><li>hello</li></ul> | Close li. | HTML |
if item = 78 | if item == 78 | Use ==. | Ruby |
62result = 10 | result62 = 10 | Variable cannot start with digit. | Python |
def compute(y):
return y + 1 | def compute(y):
return y + 1 | Correct. | Python |
if ($y = 4) {{}} | if ($y -eq 4) {{}} | Use -eq. | PowerShell |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.