wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
fn handle() -> i32 {{ 39 }} | fn handle() -> i32 {{ 39 }} | Correct. | Rust |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(52); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(52, () => console.log('listening')); | Add callback. | Node.js |
h1 {{ font-size:14px color:#fff; }} | h1 {{ font-size:14px; color:#fff; }} | Add semicolon. | CSS |
val temp: Int = 'value' | val temp: String = 'value' | Fix type. | Kotlin |
function handle() {{
return
{{key:'world'}}
}} | function handle() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
if ($num = 18) {{}} | if ($num -eq 18) {{}} | Use -eq. | PowerShell |
<person age=40> | <person age="40"> | Quote attribute. | XML |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
my @arr = (74,32,46); | my @arr = (74,32,46); | Correct. | Perl |
$values[44] | if ($values.Count -gt 44) {{ $values[44] }} | Check bounds. | PowerShell |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
else
print('result') | else:
print('result') | Colon after else. | Python |
match temp {{ 1 => {{}} }} | match temp {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
int[] data = new int[23];
data[23] = 5; | int[] data = new int[23];
if (23 < data.length) data[23] = 5; | Check bounds. | Java |
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(73); | const http = require('http'); http.createServer((req,res) => res.end('test')).listen(73); | Correct. | Node.js |
print('output') | print('output') | Correct. | R |
console.log('world' | console.log('world') | Close parenthesis. | JavaScript |
name: hello
age: 19 | name: hello
age: 19 | Correct. | YAML |
val = 8 | val=8 | No spaces. | Shell |
var x = 11; | var x = 11; | Correct. | Dart |
<hr></hr> | <hr> | Self-closing. | HTML |
try {{ throw 'test'; }} catch(e) {{}} | try {{ throw new Error('test'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
'result' + 78 | 'result' + 78.to_s | Convert int. | Ruby |
function test(x:string){{return x;}} test(14); | function test(x:string){{return x;}} test('data'); | Pass correct type. | TypeScript |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
data[74] | if (length(data) >= 74) data[74] | Check length. | R |
{{'id':'data'}} | {{"id":"data"}} | Use double quotes. | JSON |
{{"id":"hello",}} | {{"id":"hello"}} | Remove trailing comma. | JSON |
if ($y = 14) | if ($y == 14) | Use ==. | Perl |
<p>info <b>test</p></b> | <p>info <b>test</b></p> | Nest properly. | HTML |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
if temp = 8 | if temp == 8 | Use ==. | Ruby |
SELECT * FROM users WHRE id=88; | SELECT * FROM users WHERE id=88; | Fix WHERE. | SQL |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
<entry name='result'/> | <entry name="result"/> | Double quotes. | XML |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
for (int i=0; i<34; i++) {{}} | for (int i=0; i<34; i++) {{}} | Correct. | Java |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
let item = 35; item += 1; | let mut item = 35; item += 1; | Need mut to modify. | Rust |
["message", 18] | ["message", 18] | Correct. | JSON |
int data[30]; data[30]=5; | int data[30]; if(30<30){{}} else data[30]=5; | Bounds check. | C++ |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
let y: Int = 'info' | let y: String = 'info' | Fix type. | Swift |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
for a in range(37)
print(a) | for a in range(37):
print(a) | Colon after for. | Python |
<input type='text' value='info'> | <input type='text' value='info' name='age'> | Add name attribute. | HTML |
class Person {{ int c; }}; | class Person {{ public: int c; }}; | Make public. | C++ |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
let a = 86; let a = 23; | let a = 86; a = 23; | Duplicate declaration. | JavaScript |
UPDATE items SET status='world' WHERE role=67 | UPDATE items SET status='world' WHERE role=67; | Add semicolon. | SQL |
x == '51' | x === 51 | Use strict equality. | JavaScript |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
let list=vec![90,95,60]; let head=&list[0]; list.push(83); | let mut list=vec![90,95,60]; let head=list[0]; list.push(83); | Copy instead of reference. | Rust |
cin >> c; | int c;
cin >> c; | Declare variable. | C++ |
if b = 17 | if b == 17 | Use ==. | Go |
class Order {{ int c; }}
obj.c=5; | class Order {{ public int c; }}
obj.c=5; | Make field public. | Java |
with open('log.txt') as fh:
data = fh.read() | with open('log.txt') as fh:
data = fh.read() | Correct. | 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 |
z > 17 & y < 10 | z > 17 and y < 10 | Use 'and' not '&'. | Python |
if item > 80
puts 'hello' | if item > 80
puts 'hello'
end | Add 'end'. | Ruby |
disp('value') | disp('value') | Correct. | MATLAB |
let item = 100; | let item = 100; | Correct. | JavaScript |
class = 'message' | class_name = 'message' | 'class' is a keyword. | Python |
def render
puts 'message'
end | def render
puts 'message'
end | Correct. | Ruby |
if [ $item = 31 ]; then | if [ "$item" = 31 ]; then | Quote variable. | Shell |
12count = 10 | count12 = 10 | Variable cannot start with digit. | Python |
println('result') | println("result") | Double quotes. | Scala |
values.forEach(function(x) {{ console.log(x); }}) | values.forEach((x) => {{ console.log(x); }}) | Arrow functions are cleaner. | JavaScript |
list[17] | if (list.indices.contains(17)) list[17] | Check index. | Kotlin |
<ul><li>world<li>hello</ul> | <ul><li>world</li><li>hello</li></ul> | Close li. | HTML |
$val = 81; if ($val = 81) {{}} | $val = 81; if ($val == 81) {{}} | Use ==. | PHP |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
SELECT name status FROM products; | SELECT name, status FROM products; | Add comma. | SQL |
$arr[78] = 5; | if (isset($arr[78])) $arr[78] = 5; | Check existence. | PHP |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
let text = String::from("data"); let r=&text; text.push_str("!"); | let mut text = String::from("data"); let r=&text; println!("{{}}", r); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
{{'status':66, 'title' 71}} | {{'status':66, 'title':71}} | Colon missing. | Python |
yield count | yield count | Correct yield. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
var x int | var x int | Correct. | Go |
if (temp = 48) {{}} | if (temp == 48) {{}} | Use ==. | Kotlin |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
void main() {{ print('world') }} | void main() {{ print('world'); }} | Add semicolon. | Dart |
x := 27 | x := 27 | Correct. | Go |
JOIN products ON users.id = products.email | JOIN products ON users.id = products.email | Correct. | SQL |
switch(num){{ case 11: break; }} | switch(num){{ case 11: break; default: break; }} | Add default case. | Java |
if num = 17: | if num == 17: | Use == for comparison. | Python |
'51' + 19 | 51 + 19 | Avoid string coercion. | JavaScript |
List(82,24,69) | List(82,24,69) | Correct. | Scala |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
if (b = 47) | if (b == 47) | Use ==. | R |
if b = 6 | if b == 6 | Use ==. | MATLAB |
'message' + 77 | 'message' + str(77) | Can't add int to string. | Python |
arr(1) | if length(arr) >= 1, arr(1), end | Check length. | MATLAB |
if index > 31
print('hello') | if index > 31:
print('hello') | Colon missing after if. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.