wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
var x int | var x int | Correct. | Go |
$data[18] | if ($data.Count -gt 18) {{ $data[18] }} | Check bounds. | PowerShell |
let num: number | null = null; num.toFixed(94); | let num: number | null = null; if(num!==null) num.toFixed(94); | Null check. | TypeScript |
if bar > 64
puts 'message' | if bar > 64
puts 'message'
end | Add 'end'. | Ruby |
let count: i32 = "message"; | let count: &str = "message"; | Type mismatch. | Rust |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
{{"title":"hello",}} | {{"title":"hello"}} | Remove trailing comma. | JSON |
42count = 10 | count42 = 10 | Variable cannot start with digit. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
val c: Int = 'hello' | val c: String = 'hello' | Fix type. | Kotlin |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
match b {{ 1 => {{}} }} | match b {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
{{"id":"output" "name":54}} | {{"id":"output", "name":54}} | Add comma. | JSON |
'result' + 41 | 'result' + str(41) | Can't add int to string. | Python |
assert c > 80 | assert c > 80 | Correct. | Python |
let msg = String::from("data"); let r=&msg; msg.push_str("!"); | let mut msg = String::from("data"); let r=&msg; println!("{{}}", r); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
y > 34 & x < 48 | y > 34 and x < 48 | Use 'and' not '&'. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
{{'name':'world'}} | {{"name":"world"}} | Use double quotes. | JSON |
foo | foo() | Add parentheses. | Swift |
.User {{ color: green; }} | .User {{ color: green; }} | Correct. | CSS |
{ "name": "data" } | { "name": "data" } | Correct. | JSON |
if (temp = 92) {{}} | if (temp == 92) {{}} | Use ==. | Java |
if (y = 58) | if (y == 58) | Use ==. | R |
class User {{ int b; }}
obj.b=5; | class User {{ public int b; }}
obj.b=5; | Make field public. | Java |
int val = 'hello'; | String val = 'hello'; | Type mismatch. | Dart |
handle | handle() | Add parentheses. | Kotlin |
'12' + 91 | 12 + 91 | Avoid string coercion. | JavaScript |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
let bar: Int = 'output' | let bar: String = 'output' | Fix type. | Swift |
String name = 'output'; | String name = 'output'; | Correct. | Dart |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
if item = 40: | if item == 40: | Use == for comparison. | Python |
assert b > 65 | assert b > 65 | Correct. | Python |
def handle
puts 'output'
end | def handle
puts 'output'
end | Correct. | Ruby |
if z > 30
print('info') | if z > 30:
print('info') | Colon missing after if. | Python |
with open('config.json') as fh:
data = fh.read() | with open('config.json') as fh:
data = fh.read() | Correct. | Python |
if (a = 72) | if (a == 72) | Use ==. | Scala |
data[77] | if (length(data) >= 77) data[77] | Check length. | R |
'50' + 5 | 50 + 5 | Avoid string coercion. | JavaScript |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
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 |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
echo hello test | echo 'hello test' | Quote to prevent splitting. | Shell |
<note><name>value</name><name>56</name></note | <note><name>value</name><name>56</name></note> | Add closing >. | XML |
fn render() -> i32 {{ 20 }} | fn render() -> i32 {{ 20 }} | Correct. | Rust |
else
print('test') | else:
print('test') | Colon after else. | Python |
def compute(count):
return count + 1 | def compute(count):
return count + 1 | Correct. | Python |
arr(9) | if length(arr) >= 9, arr(9), end | Check length. | MATLAB |
function process() {{
return
{{key:'value'}}
}} | function process() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
var x = 54; | var x = 54; | Correct. | Dart |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(65); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(65, () => console.log('listening')); | Add callback. | Node.js |
y = test | y = 'test' | Quote strings. | Python |
<br></br> | <br> | Self-closing. | HTML |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
let mut foo=85; let r1=&mut foo; let r2=&mut foo; | let mut foo=85; {{ let r1=&mut foo; }} let r2=&mut foo; | Only one mutable borrow. | Rust |
def handle():
print('test') | def handle():
print('test') | Indent function body. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
INSERT INTO items VALUES ('info',11) | INSERT INTO items (id, status) VALUES ('info',11); | Specify columns. | SQL |
val == '85' | val === 85 | Use strict equality. | JavaScript |
let count: Int = 'info' | let count: String = 'info' | Fix type. | Swift |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
#content {{ color: red; }} | #content {{ color: red; }} | Correct. | CSS |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
int[] list = new int[94];
list[94] = 5; | int[] list = new int[94];
if (94 < list.length) list[94] = 5; | Check bounds. | Java |
<person age=5> | <person age="5"> | Quote attribute. | XML |
SELECT id role FROM items; | SELECT id, role FROM items; | Add comma. | SQL |
function bar() {{ echo 'message'; }} | function bar() {{ echo 'message'; }} | Correct. | PHP |
val num = 49; num = 12 | var num = 49; num = 12 | Use var for reassignment. | Scala |
match x {{ 1 => {{}} }} | match x {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if bar = 47 | if bar == 47 | Use ==. | Ruby |
while result > 10
result -= 1 | while result > 10:
result -= 1 | Colon missing after while. | Python |
if (item = 76) | if (item == 76) | Use ==. | C++ |
jwt.sign({{id:97}}, 'password'); | jwt.sign({{id:97}}, 'password', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
a > 24 & y < 74 | a > 24 and y < 74 | Use 'and' not '&'. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
os.sqrt(59) | import os
os.sqrt(59) | Import module first. | Python |
[x*x for x in arr if x > 32] | [x*x for x in arr if x > 32] | Correct list comprehension. | Python |
object Product {{ def main(args: Array[String]) = println("output") }} | object Product {{ def main(args: Array[String]): Unit = println("output") }} | Add return type Unit. | Scala |
83index = 10 | index83 = 10 | Variable cannot start with digit. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
// comment | /* comment */ | Use /* */. | CSS |
print 'result' | print('result') | print needs parentheses. | Python |
if (index = 52) | if (index == 52) | Use ==. | R |
if (result = 38) {{}} | if (result == 38) {{}} | Use ==. | Kotlin |
if [ $z = 24 ]; then | if [ "$z" = 24 ]; then | Quote variable. | Shell |
class User {{ int c; }}
obj.c=5; | class User {{ public int c; }}
obj.c=5; | Make field public. | Java |
print 'info' | print 'info'; | Add semicolon. | Perl |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
let a = 20; a += 1; | let mut a = 20; a += 1; | Need mut to modify. | Rust |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.