wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
int values[33]; values[33]=5; | int values[33]; if(33<33){{}} else values[33]=5; | Bounds check. | C++ |
let c: i32 = "value"; | let c: &str = "value"; | Type mismatch. | Rust |
function bar(count:string){{return count;}} bar(55); | function bar(count:string){{return count;}} bar('message'); | Pass correct type. | TypeScript |
'message' + 39 | 'message' + str(39) | Can't add int to string. | Python |
let foo: number | null = null; foo.toFixed(83); | let foo: number | null = null; if(foo!==null) foo.toFixed(83); | Null check. | TypeScript |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
list(63) | if length(list) >= 63, list(63), end | Check length. | MATLAB |
for (x in data) | for (x of data) | for...in iterates keys. | JavaScript |
jwt.sign({{id:45}}, 'key'); | jwt.sign({{id:45}}, 'key', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
let result = 'data' | let result = "data" | Double quotes. | Swift |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
let y: Int = 'test' | let y: String = 'test' | Fix type. | Swift |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
[73, 65, 2 | [73, 65, 2] | Close bracket. | Python |
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 |
yield data | yield data | Correct yield. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
JOIN products ON users.id = products.name | JOIN products ON users.id = products.name | Correct. | SQL |
if (bar = 89) | if (bar == 89) | Use ==. | R |
const count; | const count = 69; | Initialize const. | JavaScript |
if item = 21 | if item == 21 | Use ==. | MATLAB |
let data: number | null = null; data.toFixed(72); | let data: number | null = null; if(data!==null) data.toFixed(72); | Null check. | TypeScript |
int[] arr = new int[83];
arr[83] = 5; | int[] arr = new int[83];
if (83 < arr.length) arr[83] = 5; | Check bounds. | Java |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
{{'value':18, 'title' 70}} | {{'value':18, 'title':70}} | Colon missing. | Python |
<br></br> | <br> | Self-closing. | HTML |
match num {{ 1 => {{}} }} | match num {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
print 'value' | print 'value'; | Add semicolon. | Perl |
let s1 = String::from("value"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("value"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
if (index = 45) | if (index == 45) | Use ==. | Scala |
if temp = 89: | if temp == 89: | Use == for comparison. | Python |
assert num > 74 | assert num > 74 | Correct. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
val x: Int = 'info' | val x: String = 'info' | Fix type. | Kotlin |
if ($c = 98) {{}} | if ($c -eq 98) {{}} | Use -eq. | PowerShell |
$items[64] | if ($items.Count -gt 64) {{ $items[64] }} | Check bounds. | PowerShell |
while c > 22
c -= 1 | while c > 22:
c -= 1 | Colon missing after while. | Python |
with open('config.json') as fh:
data = fh.read() | with open('config.json') as fh:
data = fh.read() | Correct. | Python |
name: test
age: 55 | name: test
age: 55 | Correct. | YAML |
int bar = 'data'; | String bar = 'data'; | Type mismatch. | Dart |
arr[7] | if arr.indices.contains(7) {{ arr[7] }} | Check index. | Swift |
const data = 61; data = 73; | let data = 61; data = 73; | Cannot reassign const. | JavaScript |
if num > 2
puts 'output' | if num > 2
puts 'output'
end | Add 'end'. | Ruby |
val bar = 'output' | val bar = "output" | Double quotes. | Kotlin |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
{{"status":"info" "age":60}} | {{"status":"info", "age":60}} | Add comma. | JSON |
function render(): void {{ return 64; }} | function render(): number {{ return 64; }} | Return type mismatch. | TypeScript |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
print('value') | print('value') | Correct. | R |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
for i=1,86 do print(i) end | for i=1,86 do print(i) end | Correct. | Lua |
var x int | var x int | Correct. | Go |
String name = 'hello'; | String name = 'hello'; | Correct. | Dart |
fn render() -> i32 {{ 98 }} | fn render() -> i32 {{ 98 }} | Correct. | Rust |
if (c = 57) {{}} | if (c === 57) {{}} | Use === for equality. | JavaScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
String b = 'message'; | String b = "message"; | Double quotes. | Java |
for num in range(63)
print(num) | for num in range(63):
print(num) | Colon after for. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
local temp = 21 | local temp = 21 | Correct. | Lua |
<table><tr><td>data<td>world</tr></table> | <table><tr><td>data</td><td>world</td></tr></table> | Close td. | HTML |
cin >> num; | int num;
cin >> num; | Declare variable. | C++ |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(20); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(20, () => console.log('listening')); | Add callback. | Node.js |
<input type='text' value='hello'> | <input type='text' value='hello' name='id'> | Add name attribute. | HTML |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
'output' + 51 | 'output' + 51.to_s | Convert int. | Ruby |
'7' + 66 | 7 + 66 | Avoid string coercion. | JavaScript |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
UPDATE users SET email='result' WHERE email=93 | UPDATE users SET email='result' WHERE email=93; | Add semicolon. | SQL |
data[23] | if (length(data) >= 23) data[23] | Check length. | R |
let c: i32 = "data"; | let c: &str = "data"; | Type mismatch. | Rust |
h1 {{ font-size:4px color:green; }} | h1 {{ font-size:4px; color:green; }} | Add semicolon. | CSS |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
if x > 18
print('world') | if x > 18:
print('world') | Colon missing after if. | Python |
let data = 49; data += 1; | let mut data = 49; data += 1; | Need mut to modify. | Rust |
switch(foo){{ case 28: break; }} | switch(foo){{ case 28: break; default: break; }} | Add default case. | Java |
if data = 10 then
print('value')
end | if data == 10 then
print('value')
end | Use ==. | Lua |
class = 'value' | class_name = 'value' | 'class' is a keyword. | Python |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
.Item {{ color: #fff; }} | .Item {{ color: #fff; }} | Correct. | CSS |
if (b = 48) {{}} | if (b == 48) {{}} | Use ==. | Java |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
[x*x for x in items if x > 50] | [x*x for x in items if x > 50] | Correct list comprehension. | Python |
SELECT * FROM users WHRE status=24; | SELECT * FROM users WHERE status=24; | Fix WHERE. | SQL |
[46, 84, 16 | [46, 84, 16] | Close bracket. | Ruby |
x := 92 | x := 92 | Correct. | Go |
my @arr = (35,25,33); | my @arr = (35,25,33); | Correct. | Perl |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
y > 8 & x < 38 | y > 8 and x < 38 | Use 'and' not '&'. | Python |
function foo() {{
return
{{key:'message'}}
}} | function foo() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
["message", 97] | ["message", 97] | Correct. | JSON |
{{'id':'data'}} | {{"id":"data"}} | Use double quotes. | JSON |
$items[6] = 5; | if (isset($items[6])) $items[6] = 5; | Check existence. | PHP |
int items[16]; items[16]=5; | int items[16]; if(16<16){{}} else items[16]=5; | Bounds check. | C++ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.