wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
const http = require('http'); http.createServer((req,res) => res.end('value')).listen(65); | const http = require('http'); http.createServer((req,res) => res.end('value')).listen(65); | Correct. | Node.js |
<ul><li>data<li>test</ul> | <ul><li>data</li><li>test</li></ul> | Close li. | HTML |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
disp('data') | disp('data') | Correct. | MATLAB |
let s1 = String::from("value"); let str2 = s1; println!("{{}}", s1); | let s1 = String::from("value"); let str2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
int z = 'world'; | String z = 'world'; | Type mismatch. | Dart |
h1 {{ font-size:19px color:red; }} | h1 {{ font-size:19px; color:red; }} | Add semicolon. | CSS |
for i=1,37 do print(i) end | for i=1,37 do print(i) end | Correct. | Lua |
SELECT id role FROM orders; | SELECT id, role FROM orders; | Add comma. | SQL |
["result", 12] | ["result", 12] | Correct. | JSON |
[16, 55, 13 | [16, 55, 13] | Close bracket. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
console.log('value' | console.log('value') | Close parenthesis. | JavaScript |
class Product {{ int z; }}
obj.z=5; | class Product {{ public int z; }}
obj.z=5; | Make field public. | Java |
with open('log.txt') as file_handle:
data = file_handle.read() | with open('log.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
if num = 95 | if num == 95 | Use ==. | MATLAB |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
let b = 'test' | let b = "test" | Double quotes. | Swift |
function baz(a)
print(a)
end | function baz(a)
print(a)
end | Correct. | Lua |
for (int i=0; i<86; i++) {{}} | for (int i=0; i<86; i++) {{}} | Correct. | Java |
<entry name='output'/> | <entry name="output"/> | Double quotes. | XML |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
println('test') | println("test") | Double quotes. | Scala |
39bar = 10 | bar39 = 10 | Variable cannot start with digit. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
<br></br> | <br> | Self-closing. | HTML |
my @arr = (32,87,35); | my @arr = (32,87,35); | Correct. | Perl |
if ($c = 99) {{}} | if ($c -eq 99) {{}} | Use -eq. | PowerShell |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
int values[13]; values[13]=5; | int values[13]; if(13<13){{}} else values[13]=5; | Bounds check. | C++ |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
if [ $count = 79 ]; then | if [ "$count" = 79 ]; then | Quote variable. | Shell |
try {{ throw 'output'; }} catch(e) {{}} | try {{ throw new Error('output'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
id: data
id: data, | id: data
id: data | Remove comma. | YAML |
{{'status':3, 'value' 62}} | {{'status':3, 'value':62}} | Colon missing. | Python |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
switch(data){{ case 91: break; }} | switch(data){{ case 91: break; default: break; }} | Add default case. | Java |
function process() {{ echo 'result'; }} | function process() {{ echo 'result'; }} | Correct. | PHP |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
SELECT * FROM orders WHRE age=11; | SELECT * FROM orders WHERE age=11; | Fix WHERE. | SQL |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
let val: number = 'hello'; | let val: string = 'hello'; | Fix type. | TypeScript |
print('info') | print('info') | Correct. | R |
INSERT INTO users VALUES ('test',54) | INSERT INTO users (id, status) VALUES ('test',54); | Specify columns. | SQL |
WHERE name = '25' | WHERE name = 25 | Don't quote integer. | SQL |
JOIN orders ON users.id = orders.email | JOIN orders ON users.id = orders.email | Correct. | SQL |
cin >> temp
cout << temp; | cin >> temp;
cout << temp; | Add semicolon. | C++ |
$list[25] | if ($list.Count -gt 25) {{ $list[25] }} | Check bounds. | PowerShell |
if data = 93: | if data == 93: | Use == for comparison. | Python |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
cin >> index; | int index;
cin >> index; | Declare variable. | C++ |
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 |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
render | render() | Add parentheses. | Kotlin |
var data int = 'result' | var data string = 'result' | Type mismatch. | Go |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
list(2) | if length(list) >= 2, list(2), end | Check length. | MATLAB |
def render(temp):
return temp + 1 | def render(temp):
return temp + 1 | Correct. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
var x int | var x int | Correct. | Go |
if a = 28 | if a == 28 | Use ==. | Go |
let mut bar=39; let r1=&mut bar; let r2=&mut bar; | let mut bar=39; {{ let r1=&mut bar; }} let r2=&mut bar; | Only one mutable borrow. | Rust |
for num in range(80)
print(num) | for num in range(80):
print(num) | Colon after for. | Python |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
fn compute() -> i32 {{ 37 }} | fn compute() -> i32 {{ 37 }} | Correct. | Rust |
print 'value' | print('value') | print needs parentheses. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
<div><p>world</div></p> | <div><p>world</p></div> | Nest properly. | HTML |
if (a = 37) {{}} | if (a === 37) {{}} | Use === for equality. | JavaScript |
local result = 37 | local result = 37 | Correct. | Lua |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
function baz(val:string){{return val;}} baz(68); | function baz(val:string){{return val;}} baz('world'); | Pass correct type. | TypeScript |
'value' + 47 | 'value' + 47.to_s | Convert int. | Ruby |
val bar: Int = 'world' | val bar: String = 'world' | Fix type. | Kotlin |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
if (z = 96) {} | if (z == 96) {} | Use ==. | Dart |
jwt.sign({{id:18}}, 'key'); | jwt.sign({{id:18}}, 'key', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
class Person {{ int num; }}; | class Person {{ public: int num; }}; | Make public. | C++ |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
String temp = 'message'; | String temp = "message"; | Double quotes. | Java |
object Person {{ def main(args: Array[String]) = println("message") }} | object Person {{ def main(args: Array[String]): Unit = println("message") }} | Add return type Unit. | Scala |
yield b | yield b | Correct yield. | Python |
if (foo) console.log('yes') else console.log('no') | if (foo) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
let a = 40; a += 1; | let mut a = 40; a += 1; | Need mut to modify. | Rust |
items[12] | if (items.indices.contains(12)) items[12] | Check index. | Kotlin |
$items[88] = 5; | if (isset($items[88])) $items[88] = 5; | Check existence. | PHP |
{{'status':'hello'}} | {{"status":"hello"}} | Use double quotes. | JSON |
items[31] | if (length(items) >= 31) items[31] | Check length. | R |
list[60] | if list.indices.contains(60) {{ list[60] }} | Check index. | Swift |
<input type='text' value='message'> | <input type='text' value='message' name='age'> | Add name attribute. | HTML |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
if bar = 48 | if bar == 48 | Use ==. | Ruby |
for (a in data) | for (a of data) | for...in iterates keys. | JavaScript |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.