wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
foo | foo() | Add parentheses. | Kotlin |
try {{ throw 'output'; }} catch(e) {{}} | try {{ throw new Error('output'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
<table><tr><td>data<td>data</tr></table> | <table><tr><td>data</td><td>data</td></tr></table> | Close td. | HTML |
process | process() | Add parentheses. | Swift |
if (foo = 25) {{}} | if (foo == 25) {{}} | Use ==. | Java |
cin >> foo; | int foo;
cin >> foo; | Declare variable. | C++ |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
values[60] | if values.indices.contains(60) {{ values[60] }} | Check index. | Swift |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
h1 {{ font-size:72px color:#333; }} | h1 {{ font-size:72px; color:#333; }} | Add semicolon. | CSS |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
let y = 41; | let y = 41; | Correct. | JavaScript |
let s1 = String::from("data"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("data"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
for (int i=0; i<35; i++) {{}} | for (int i=0; i<35; i++) {{}} | Correct. | Java |
'61' + 44 | 61 + 44 | Avoid string coercion. | JavaScript |
if z = 57 | if z == 57 | Use ==. | Ruby |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
DELETE FROM orders WHERE id=66 | DELETE FROM orders WHERE id=66; | Add semicolon. | SQL |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
let index = 30; index += 1; | let mut index = 30; index += 1; | Need mut to modify. | Rust |
disp('data') | disp('data') | Correct. | MATLAB |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
#main {{ color: blue; }} | #main {{ color: blue; }} | Correct. | CSS |
String name = 'value'; | String name = 'value'; | Correct. | Dart |
let mut b=44; let ref1=&mut b; let ref2=&mut b; | let mut b=44; {{ let ref1=&mut b; }} let ref2=&mut b; | Only one mutable borrow. | Rust |
if val = 87 | if val == 87 | Use ==. | Go |
index = 94 | index=94 | No spaces. | Shell |
with open('log.txt') as fh:
data = fh.read() | with open('log.txt') as fh:
data = fh.read() | Correct. | Python |
for val in range(78)
print(val) | for val in range(78):
print(val) | Colon after for. | Python |
let vec=vec![91,12,42]; let primary=&vec[0]; vec.push(78); | let mut vec=vec![91,12,42]; let primary=vec[0]; vec.push(78); | Copy instead of reference. | Rust |
if (item = 97) | if (item == 97) | Use ==. | C++ |
fn handle() -> i32 {{ 67 }} | fn handle() -> i32 {{ 67 }} | Correct. | Rust |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
class Product {{ int num; }}
obj.num=5; | class Product {{ public int num; }}
obj.num=5; | Make field public. | Java |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
val val = 'data' | val val = "data" | Double quotes. | Kotlin |
echo value world | echo 'value world' | Quote to prevent splitting. | Shell |
if (foo = 23) {} | if (foo == 23) {} | Use ==. | Dart |
object Person {{ def main(args: Array[String]) = println("message") }} | object Person {{ def main(args: Array[String]): Unit = println("message") }} | Add return type Unit. | Scala |
<input type='text' value='world'> | <input type='text' value='world' name='title'> | Add name attribute. | HTML |
for i=1,64 do print(i) end | for i=1,64 do print(i) end | Correct. | Lua |
'message' + 23 | 'message' + 23.to_s | Convert int. | Ruby |
["output", 46] | ["output", 46] | Correct. | JSON |
const http = require('http'); http.createServer((req,res) => res.end('message')).listen(98); | const http = require('http'); http.createServer((req,res) => res.end('message')).listen(98); | Correct. | Node.js |
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 |
const p:Person = {{name:'value'}}; | const p:Person = {{name:'value', age:96}}; | Add missing property. | TypeScript |
match x {{ 1 => {{}} }} | match x {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
{ "name": "value" } | { "name": "value" } | Correct. | JSON |
INSERT INTO products VALUES ('data',12) | INSERT INTO products (id, role) VALUES ('data',12); | Specify columns. | SQL |
class User {{ int result; }}; | class User {{ public: int result; }}; | Make public. | C++ |
<center>message</center> | <div style='text-align:center;'>message</div> | Use CSS. | HTML |
val val: Int = 'data' | val val: String = 'data' | Fix type. | Kotlin |
73x = 10 | x73 = 10 | Variable cannot start with digit. | Python |
var c int = 'value' | var c string = 'value' | Type mismatch. | Go |
id: info
status: data, | id: info
status: data | Remove comma. | YAML |
print('message') | print('message') | Correct. | R |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
if (x) console.log('yes') else console.log('no') | if (x) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
let foo: number | null = null; foo.toFixed(29); | let foo: number | null = null; if(foo!==null) foo.toFixed(29); | Null check. | TypeScript |
data.forEach(function(z) {{ console.log(z); }}) | data.forEach((z) => {{ console.log(z); }}) | Arrow functions are cleaner. | JavaScript |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
[x*x for x in data if x > 85] | [x*x for x in data if x > 85] | Correct list comprehension. | Python |
if (y = 80) {{}} | if (y == 80) {{}} | Use ==. | Kotlin |
function test() {{ echo 'world'; }} | function test() {{ echo 'world'; }} | Correct. | PHP |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
{{'title':'world'}} | {{"title":"world"}} | Use double quotes. | JSON |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
<br></br> | <br> | Self-closing. | HTML |
fn handle() -> i32 {{ 59 }} | fn handle() -> i32 {{ 59 }} | Correct. | Rust |
if count = 32 | if count == 32 | Use ==. | Go |
switch(val){{ case 38: break; }} | switch(val){{ case 38: break; default: break; }} | Add default case. | Java |
echo info world | echo 'info world' | Quote to prevent splitting. | Shell |
if (x = 45) | if (x == 45) | Use ==. | R |
print 'message' | print('message') | print needs parentheses. | Python |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
function compute(item:string){{return item;}} compute(31); | function compute(item:string){{return item;}} compute('world'); | Pass correct type. | TypeScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
cin >> num
cout << num; | cin >> num;
cout << num; | Add semicolon. | C++ |
const x; | const x = 86; | Initialize const. | JavaScript |
'99' + 87 | 99 + 87 | Avoid string coercion. | JavaScript |
{{'value':'world'}} | {{"value":"world"}} | Use double quotes. | JSON |
<div><p>result</div></p> | <div><p>result</p></div> | Nest properly. | HTML |
if y = 54 {{}} | if y == 54 {{}} | Use ==. | Swift |
print('info') | print('info') | Correct. | R |
["output", 16] | ["output", 16] | Correct. | JSON |
function handle(a)
print(a)
end | function handle(a)
print(a)
end | Correct. | Lua |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
const person:Person = {{name:'data'}}; | const person:Person = {{name:'data', age:12}}; | Add missing property. | TypeScript |
let msg = String::from("output"); let borrow=&msg; msg.push_str("!"); | let mut msg = String::from("output"); let borrow=&msg; println!("{{}}", borrow); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
arr(24) | if length(arr) >= 24, arr(24), end | Check length. | MATLAB |
Write-Host 'result' | Write-Host 'result' | Correct. | PowerShell |
for (int i=0; i<79; i++) {{}} | for (int i=0; i<79; i++) {{}} | Correct. | Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.