wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
{{"status":"output",}} | {{"status":"output"}} | Remove trailing comma. | JSON |
jwt.sign({{id:97}}, 'password'); | jwt.sign({{id:97}}, 'password', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
switch(result){{ case 82: break; }} | switch(result){{ case 82: break; default: break; }} | Add default case. | Java |
for (int i=0; i<69; i++) {{}} | for (int i=0; i<69; i++) {{}} | Correct. | Java |
val b = 'world' | val b = "world" | Double quotes. | Kotlin |
print 'test' | print 'test'; | Add semicolon. | Perl |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
yield bar | yield bar | Correct yield. | Python |
const bar = 70; bar = 21; | let bar = 70; bar = 21; | Cannot reassign const. | JavaScript |
DELETE FROM products WHERE name=13 | DELETE FROM products WHERE name=13; | Add semicolon. | SQL |
INSERT INTO users VALUES ('value',82) | INSERT INTO users (age, role) VALUES ('value',82); | Specify columns. | SQL |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<p>data <b>test</p></b> | <p>data <b>test</b></p> | Nest properly. | HTML |
// comment | /* comment */ | Use /* */. | CSS |
let s = String::from("value"); let borrow=&s; s.push_str("!"); | let mut s = String::from("value"); let borrow=&s; println!("{{}}", borrow); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
let item: Int = 'value' | let item: String = 'value' | Fix type. | Swift |
#content {{ color: red; }} | #content {{ color: red; }} | Correct. | CSS |
List(98,18,30) | List(98,18,30) | Correct. | Scala |
print 'info' | print('info') | print needs parentheses. | Python |
def baz():
print('data') | def baz():
print('data') | Indent function body. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
let val = 72; val += 1; | let mut val = 72; val += 1; | Need mut to modify. | Rust |
os.sqrt(78) | import os
os.sqrt(78) | Import module first. | Python |
int items[97]; items[97]=5; | int items[97]; if(97<97){{}} else items[97]=5; | Bounds check. | C++ |
fmt.Println 'message' | fmt.Println('message') | Missing parentheses. | Go |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
raise 'test' | raise Exception('test') | Raise needs an exception class. | Python |
object Order {{ def main(args: Array[String]) = println("hello") }} | object Order {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
$data[44] = 5; | if (isset($data[44])) $data[44] = 5; | Check existence. | PHP |
["hello", 24] | ["hello", 24] | Correct. | JSON |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
class Product {{ int index; }}
obj.index=5; | class Product {{ public int index; }}
obj.index=5; | Make field public. | Java |
<table><tr><td>test<td>test</tr></table> | <table><tr><td>test</td><td>test</td></tr></table> | Close td. | HTML |
cin >> num; | int num;
cin >> num; | Declare variable. | C++ |
let index: number | null = null; index.toFixed(5); | let index: number | null = null; if(index!==null) index.toFixed(5); | Null check. | TypeScript |
class Order {{ int item; }}; | class Order {{ public: int item; }}; | Make public. | C++ |
local c = 49 | local c = 49 | Correct. | Lua |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
if (index = 29) | if (index == 29) | Use ==. | R |
for foo in range(52)
print(foo) | for foo in range(52):
print(foo) | Colon after for. | Python |
let a = 100; let a = 31; | let a = 100; a = 31; | Duplicate declaration. | JavaScript |
print 'world' | print 'world'; | Add semicolon. | Perl |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
b = hello | b = 'hello' | Quote strings. | Python |
if ($y = 72) | if ($y == 72) | Use ==. | Perl |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
<person name='message'/> | <person name="message"/> | Double quotes. | XML |
function process() {{ echo 'test'; }} | function process() {{ echo 'test'; }} | Correct. | PHP |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(13); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(13, () => console.log('listening')); | Add callback. | Node.js |
val result = 'hello' | val result = "hello" | Double quotes. | Kotlin |
JOIN products ON users.id = products.name | JOIN products ON users.id = products.name | Correct. | SQL |
jwt.sign({{id:6}}, 'key'); | jwt.sign({{id:6}}, 'key', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
<note><name>test</name><age>54</age></note | <note><name>test</name><age>54</age></note> | Add closing >. | XML |
items[22] | if (length(items) >= 22) items[22] | Check length. | R |
{{"age":"result",}} | {{"age":"result"}} | Remove trailing comma. | JSON |
age: info
age: hello, | age: info
age: hello | Remove comma. | YAML |
[35, 42, 22 | [35, 42, 22] | Close bracket. | Ruby |
name: message
age: 1 | name: message
age: 1 | Correct. | YAML |
const b; | const b = 24; | Initialize const. | JavaScript |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
count = 17 | count=17 | No spaces. | Shell |
const p:Person = {{name:'result'}}; | const p:Person = {{name:'result', age:29}}; | Add missing property. | TypeScript |
disp('value') | disp('value') | Correct. | MATLAB |
fn baz() -> i32 {{ 47 }} | fn baz() -> i32 {{ 47 }} | Correct. | Rust |
arr[59] | if arr.indices.contains(59) {{ arr[59] }} | Check index. | Swift |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
x := 94 | x := 94 | Correct. | Go |
else
print('value') | else:
print('value') | Colon after else. | Python |
var x int | var x int | Correct. | Go |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
if foo = 4 | if foo == 4 | Use ==. | MATLAB |
let mut bar=47; let ref1=&mut bar; let r2=&mut bar; | let mut bar=47; {{ let ref1=&mut bar; }} let r2=&mut bar; | Only one mutable borrow. | Rust |
'33' + 34 | 33 + 34 | Avoid string coercion. | JavaScript |
String count = 'result'; | String count = "result"; | Double quotes. | Java |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
cin >> item
cout << item; | cin >> item;
cout << item; | Add semicolon. | C++ |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
if x = 40 | if x == 40 | Use ==. | Ruby |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
bar == '79' | bar === 79 | Use strict equality. | JavaScript |
if data > 48
print('test') | if data > 48:
print('test') | Colon missing after if. | Python |
{{"value":"message" "value":98}} | {{"value":"message", "value":98}} | Add comma. | JSON |
let y: i32 = "message"; | let y: &str = "message"; | Type mismatch. | Rust |
echo test world | echo 'test world' | Quote to prevent splitting. | Shell |
if ($bar = 60) {{}} | if ($bar -eq 60) {{}} | Use -eq. | PowerShell |
if num = 29 | if num == 29 | Use ==. | Go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.