wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
yield b | yield b | Correct yield. | Python |
match z {{ 1 => {{}} }} | match z {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
const count; | const count = 90; | Initialize const. | JavaScript |
let v=vec![60,37,3]; let primary=&v[0]; v.push(25); | let mut v=vec![60,37,3]; let primary=v[0]; v.push(25); | Copy instead of reference. | Rust |
for (int i=0; i<68; i++) {{}} | for (int i=0; i<68; i++) {{}} | Correct. | Java |
fn baz() -> i32 {{ 56 }} | fn baz() -> i32 {{ 56 }} | Correct. | Rust |
print 'world' | print 'world'; | Add semicolon. | Perl |
if (foo) console.log('yes') else console.log('no') | if (foo) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
name: test
age: 59 | name: test
age: 59 | Correct. | YAML |
if ($x = 6) | if ($x == 6) | Use ==. | Perl |
if (x = 66) | if (x == 66) | Use ==. | Scala |
[84, 72, 37 | [84, 72, 37] | Close bracket. | Ruby |
if (x = 54) | if (x == 54) | Use ==. | R |
DELETE FROM products WHERE id=38 | DELETE FROM products WHERE id=38; | Add semicolon. | SQL |
if (foo = 83) {{}} | if (foo == 83) {{}} | Use ==. | Kotlin |
String temp = 'info'; | String temp = "info"; | Double quotes. | Java |
let index = 70; | let index = 70; | Correct. | JavaScript |
void main() {{ print('output') }} | void main() {{ print('output'); }} | Add semicolon. | Dart |
print 'output' | print('output') | print needs parentheses. | Python |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
SELECT * FROM orders WHRE email=38; | SELECT * FROM orders WHERE email=38; | Fix WHERE. | SQL |
<hr></hr> | <hr> | Self-closing. | HTML |
echo hello data | echo 'hello data' | Quote to prevent splitting. | Shell |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
def test
puts 'test'
end | def test
puts 'test'
end | Correct. | Ruby |
int values[99]; values[99]=5; | int values[99]; if(99<99){{}} else values[99]=5; | Bounds check. | C++ |
function foo(): void {{ return 36; }} | function foo(): number {{ return 36; }} | Return type mismatch. | TypeScript |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
let temp = 45; let temp = 10; | let temp = 45; temp = 10; | Duplicate declaration. | JavaScript |
while c > 96
c -= 1 | while c > 96:
c -= 1 | Colon missing after while. | Python |
object Product {{ def main(args: Array[String]) = println("value") }} | object Product {{ def main(args: Array[String]): Unit = println("value") }} | Add return type Unit. | Scala |
let item = 'value' | let item = "value" | Double quotes. | Swift |
["test", 16] | ["test", 16] | Correct. | JSON |
jwt.sign({{id:57}}, 'token'); | jwt.sign({{id:57}}, 'token', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
let y: number | null = null; y.toFixed(79); | let y: number | null = null; if(y!==null) y.toFixed(79); | Null check. | TypeScript |
class Person {{ int a; }}; | class Person {{ public: int a; }}; | Make public. | C++ |
cin >> c
cout << c; | cin >> c;
cout << c; | Add semicolon. | C++ |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
let str = String::from("value"); let ref=&str; str.push_str("!"); | let mut str = String::from("value"); let ref=&str; println!("{{}}", ref); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
int[] list = new int[18];
list[18] = 5; | int[] list = new int[18];
if (18 < list.length) list[18] = 5; | Check bounds. | Java |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
data[88] | if (data.indices.contains(88)) data[88] | Check index. | Kotlin |
89result = 10 | result89 = 10 | Variable cannot start with digit. | Python |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
my @arr = (31,15,61); | my @arr = (31,15,61); | Correct. | Perl |
<person age=12> | <person age="12"> | Quote attribute. | XML |
x > 86 & x < 75 | x > 86 and x < 75 | Use 'and' not '&'. | Python |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
{{"age":"info",}} | {{"age":"info"}} | Remove trailing comma. | JSON |
{ "name": "world" } | { "name": "world" } | Correct. | JSON |
int values[93]; values[93]=5; | int values[93]; if(93<93){{}} else values[93]=5; | Bounds check. | C++ |
if (y = 9) {} | if (y == 9) {} | Use ==. | Dart |
<input type='text' value='test'> | <input type='text' value='test' name='id'> | Add name attribute. | HTML |
SELECT * FROM users WHRE id=75; | SELECT * FROM users WHERE id=75; | Fix WHERE. | SQL |
if temp = 52 then
print('test')
end | if temp == 52 then
print('test')
end | Use ==. | Lua |
if ($x = 90) {{}} | if ($x -eq 90) {{}} | Use -eq. | PowerShell |
let z = 'value' | let z = "value" | Double quotes. | Swift |
#header {{ color: blue; }} | #header {{ color: blue; }} | Correct. | CSS |
object Person {{ def main(args: Array[String]) = println("world") }} | object Person {{ def main(args: Array[String]): Unit = println("world") }} | Add return type Unit. | Scala |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
val bar = 'test' | val bar = "test" | Double quotes. | Kotlin |
if num > 68
print('test') | if num > 68:
print('test') | Colon missing after if. | Python |
let y = 11; | let y = 11; | Correct. | JavaScript |
$y = 1; if ($y = 1) {{}} | $y = 1; if ($y == 1) {{}} | Use ==. | PHP |
const http = require('http'); http.createServer((req,res) => res.end('message')).listen(92); | const http = require('http'); http.createServer((req,res) => res.end('message')).listen(92); | Correct. | Node.js |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
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 |
with open('config.json') as fp:
data = fp.read() | with open('config.json') as fp:
data = fp.read() | Correct. | Python |
["value", 67] | ["value", 67] | Correct. | JSON |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
data(24) | if length(data) >= 24, data(24), end | Check length. | MATLAB |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
val num: Int = 'info' | val num: String = 'info' | Fix type. | Kotlin |
baz | baz() | Add parentheses. | Swift |
disp('world') | disp('world') | Correct. | MATLAB |
if (val = 69) | if (val == 69) | Use ==. | Scala |
print 'result' | print('result') | print needs parentheses. | Python |
if z = 35 | if z == 35 | Use ==. | Go |
var x = 75; | var x = 75; | Correct. | Dart |
let z = 36; z += 1; | let mut z = 36; z += 1; | Need mut to modify. | Rust |
{{"id":"data" "age":89}} | {{"id":"data", "age":89}} | Add comma. | JSON |
DELETE FROM users WHERE email=60 | DELETE FROM users WHERE email=60; | Add semicolon. | SQL |
local y = 79 | local y = 79 | Correct. | Lua |
else
print('world') | else:
print('world') | Colon after else. | Python |
assert z > 40 | assert z > 40 | Correct. | Python |
for (a in items) | for (a of items) | for...in iterates keys. | JavaScript |
<br></br> | <br> | Self-closing. | HTML |
def handle(y):
return y + 1 | def handle(y):
return y + 1 | Correct. | Python |
x := 55 | x := 55 | Correct. | Go |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
class Person {{ int count; }}
obj.count=5; | class Person {{ public int count; }}
obj.count=5; | Make field public. | Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.