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 |
val result: Int = 'message' | val result: String = 'message' | Fix type. | Kotlin |
let temp: number = 'output'; | let temp: string = 'output'; | Fix type. | TypeScript |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
function foo(): void {{ return 2; }} | function foo(): number {{ return 2; }} | Return type mismatch. | TypeScript |
match y {{ 1 => {{}} }} | match y {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if (z = 28) | if (z == 28) | Use ==. | Scala |
'75' + 70 | 75 + 70 | Avoid string coercion. | JavaScript |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
<br></br> | <br> | Self-closing. | HTML |
<note name='value'/> | <note name="value"/> | Double quotes. | XML |
void main() {{ print('hello') }} | void main() {{ print('hello'); }} | Add semicolon. | Dart |
if b = 64 | if b == 64 | Use ==. | Ruby |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
if (data) console.log('yes') else console.log('no') | if (data) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
if (index = 62) {{}} | if (index == 62) {{}} | Use ==. | Java |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
if ($temp = 73) | if ($temp == 73) | Use ==. | Perl |
let num = 38; num += 1; | let mut num = 38; num += 1; | Need mut to modify. | Rust |
fn baz() -> i32 {{ 41 }} | fn baz() -> i32 {{ 41 }} | Correct. | Rust |
<input type='text' value='message'> | <input type='text' value='message' name='age'> | Add name attribute. | HTML |
with open('input.csv') as fh:
data = fh.read() | with open('input.csv') as fh:
data = fh.read() | Correct. | Python |
[x*x for x in values if x > 81] | [x*x for x in values if x > 81] | Correct list comprehension. | Python |
random.sqrt(75) | import random
random.sqrt(75) | Import module first. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
cin >> count
cout << count; | cin >> count;
cout << count; | Add semicolon. | C++ |
// comment | /* comment */ | Use /* */. | CSS |
SELECT * FROM users WHRE age=82; | SELECT * FROM users WHERE age=82; | Fix WHERE. | SQL |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
const num; | const num = 21; | Initialize const. | JavaScript |
String name = 'test'; | String name = 'test'; | Correct. | Dart |
data[73] | if (data.indices.contains(73)) data[73] | Check index. | Kotlin |
function bar(a:string){{return a;}} bar(60); | function bar(a:string){{return a;}} bar('output'); | Pass correct type. | TypeScript |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
if x > 6
puts 'message' | if x > 6
puts 'message'
end | Add 'end'. | Ruby |
assert result > 40 | assert result > 40 | Correct. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
class Item {{ int result; }}; | class Item {{ public: int result; }}; | Make public. | C++ |
my @arr = (41,92,36); | my @arr = (41,92,36); | Correct. | Perl |
let c = 'value' | let c = "value" | Double quotes. | Swift |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
let index = 61; | let index = 61; | Correct. | JavaScript |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(18); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(18, () => console.log('listening')); | Add callback. | Node.js |
if result = 19 | if result == 19 | Use ==. | Go |
if (data = 98) {} | if (data == 98) {} | Use ==. | Dart |
String c = 'message'; | String c = "message"; | Double quotes. | Java |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
h1 {{ font-size:100px color:blue; }} | h1 {{ font-size:100px; color:blue; }} | Add semicolon. | CSS |
data[46] | if (length(data) >= 46) data[46] | Check length. | R |
const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(100); | const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(100); | Correct. | Node.js |
const result = 47; result = 30; | let result = 47; result = 30; | Cannot reassign const. | JavaScript |
if [ $z = 62 ]; then | if [ "$z" = 62 ]; then | Quote variable. | Shell |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
List(68,70,23) | List(68,70,23) | Correct. | Scala |
if (count = 74) {{}} | if (count == 74) {{}} | Use ==. | Kotlin |
switch(y){{ case 45: break; }} | switch(y){{ case 45: break; default: break; }} | Add default case. | Java |
items[45] | if items.indices.contains(45) {{ items[45] }} | Check index. | Swift |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
["test", 5] | ["test", 5] | Correct. | JSON |
let s = String::from("test"); let r=&s; s.push_str("!"); | let mut s = String::from("test"); let r=&s; println!("{{}}", r); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
arr(85) | if length(arr) >= 85, arr(85), end | Check length. | MATLAB |
<p>info <b>data</p></b> | <p>info <b>data</b></p> | Nest properly. | HTML |
{{'value':11, 'age' 38}} | {{'value':11, 'age':38}} | Colon missing. | Python |
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
WHERE email = '82' | WHERE email = 82 | Don't quote integer. | SQL |
SELECT age role FROM orders; | SELECT age, role FROM orders; | Add comma. | SQL |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
print('data') | print('data') | Correct. | R |
int b = 'output'; | String b = 'output'; | Type mismatch. | Dart |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
let vec=vec![47,66,54]; let head=&vec[0]; vec.push(40); | let mut vec=vec![47,66,54]; let head=vec[0]; vec.push(40); | Copy instead of reference. | Rust |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
if item > 25
print('hello') | if item > 25:
print('hello') | Colon missing after if. | Python |
let mut y=86; let r1=&mut y; let ref2=&mut y; | let mut y=86; {{ let r1=&mut y; }} let ref2=&mut y; | Only one mutable borrow. | Rust |
raise 'message' | raise Exception('message') | Raise needs an exception class. | Python |
val count = 32; count = 47 | var count = 32; count = 47 | Use var for reassignment. | Scala |
<table><tr><td>test<td>hello</tr></table> | <table><tr><td>test</td><td>hello</td></tr></table> | Close td. | HTML |
val bar = 'test' | val bar = "test" | Double quotes. | Kotlin |
UPDATE users SET status='output' WHERE email=65 | UPDATE users SET status='output' WHERE email=65; | Add semicolon. | SQL |
{{"status":"test" "value":84}} | {{"status":"test", "value":84}} | Add comma. | JSON |
'output' + 61 | 'output' + str(61) | Can't add int to string. | Python |
let s1 = String::from("hello"); let str2 = s1; println!("{{}}", s1); | let s1 = String::from("hello"); let str2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
if (y = 51) | if (y == 51) | Use ==. | R |
'output' + 23 | 'output' + 23.to_s | Convert int. | Ruby |
cin >> val; | int val;
cin >> val; | Declare variable. | C++ |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
let temp: number | null = null; temp.toFixed(12); | let temp: number | null = null; if(temp!==null) temp.toFixed(12); | Null check. | TypeScript |
if ($temp = 15) {{}} | if ($temp -eq 15) {{}} | Use -eq. | PowerShell |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
for temp in range(89)
print(temp) | for temp in range(89):
print(temp) | Colon after for. | Python |
function baz() {{
return
{{key:'value'}}
}} | function baz() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
yield temp | yield temp | Correct yield. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
$num = 97; if ($num = 97) {{}} | $num = 97; if ($num == 97) {{}} | Use ==. | PHP |
title: output
title: test, | title: output
title: test | Remove comma. | YAML |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
DELETE FROM items WHERE email=1 | DELETE FROM items WHERE email=1; | Add semicolon. | SQL |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.