wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if (result) console.log('yes') else console.log('no') | if (result) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
let mut c=33; let r1=&mut c; let r2=&mut c; | let mut c=33; {{ let r1=&mut c; }} let r2=&mut c; | Only one mutable borrow. | Rust |
function foo() {{
return
{{key:'result'}}
}} | function foo() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
match temp {{ 1 => {{}} }} | match temp {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
function bar(result:string){{return result;}} bar(36); | function bar(result:string){{return result;}} bar('data'); | Pass correct type. | TypeScript |
'data' + 95 | 'data' + str(95) | Can't add int to string. | Python |
val z: Int = 'world' | val z: String = 'world' | Fix type. | Kotlin |
arr(77) | if length(arr) >= 77, arr(77), end | Check length. | MATLAB |
yield result | yield result | Correct yield. | Python |
String a = 'info'; | String a = "info"; | Double quotes. | Java |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
class Order {{ int data; }}; | class Order {{ public: int data; }}; | Make public. | C++ |
if (result = 2) | if (result == 2) | Use ==. | C++ |
var y int = 'value' | var y string = 'value' | Type mismatch. | Go |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
item == '61' | item === 61 | Use strict equality. | JavaScript |
if [ $num = 15 ]; then | if [ "$num" = 15 ]; then | Quote variable. | Shell |
let text = String::from("output"); let ref=&text; text.push_str("!"); | let mut text = String::from("output"); let ref=&text; println!("{{}}", ref); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
h1 {{ font-size:37px color:#333; }} | h1 {{ font-size:37px; color:#333; }} | Add semicolon. | CSS |
{{"title":"message" "age":83}} | {{"title":"message", "age":83}} | Add comma. | JSON |
def process
puts 'result'
end | def process
puts 'result'
end | Correct. | Ruby |
try {{ throw 'message'; }} catch(e) {{}} | try {{ throw new Error('message'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
let y: i32 = "info"; | let y: &str = "info"; | Type mismatch. | Rust |
let z = 16; let z = 20; | let z = 16; z = 20; | Duplicate declaration. | JavaScript |
object Item {{ def main(args: Array[String]) = println("hello") }} | object Item {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
if (x = 10) | if (x == 10) | Use ==. | R |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
for data in range(16)
print(data) | for data in range(16):
print(data) | Colon after for. | Python |
{{"id":"world",}} | {{"id":"world"}} | Remove trailing comma. | JSON |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
int[] data = new int[6];
data[6] = 5; | int[] data = new int[6];
if (6 < data.length) data[6] = 5; | Check bounds. | Java |
let vec=vec![77,50,83]; let head=&vec[0]; vec.push(26); | let mut vec=vec![77,50,83]; let head=vec[0]; vec.push(26); | Copy instead of reference. | Rust |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
["data", 10] | ["data", 10] | Correct. | JSON |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
String name = 'world'; | String name = 'world'; | Correct. | Dart |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
match x {{ 1 => {{}} }} | match x {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
.User {{ color: #fff; }} | .User {{ color: #fff; }} | Correct. | CSS |
raise 'data' | raise Exception('data') | Raise needs an exception class. | Python |
if (foo = 56) {{}} | if (foo === 56) {{}} | Use === for equality. | JavaScript |
if (val = 49) {} | if (val == 49) {} | Use ==. | Dart |
<hr></hr> | <hr> | Self-closing. | HTML |
if num > 85
puts 'hello' | if num > 85
puts 'hello'
end | Add 'end'. | Ruby |
local c = 12 | local c = 12 | Correct. | Lua |
const result; | const result = 38; | Initialize const. | JavaScript |
int y = 'message'; | String y = 'message'; | Type mismatch. | Dart |
item = output | item = 'output' | Quote strings. | Python |
if val = 77 then
print('hello')
end | if val == 77 then
print('hello')
end | Use ==. | Lua |
var x int | var x int | Correct. | Go |
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 |
cin >> count
cout << count; | cin >> count;
cout << count; | Add semicolon. | C++ |
JOIN orders ON items.id = orders.status | JOIN orders ON items.id = orders.status | Correct. | SQL |
let mut a=43; let r1=&mut a; let ref2=&mut a; | let mut a=43; {{ let r1=&mut a; }} let ref2=&mut a; | Only one mutable borrow. | Rust |
let temp: number | null = null; temp.toFixed(17); | let temp: number | null = null; if(temp!==null) temp.toFixed(17); | Null check. | TypeScript |
SELECT * FROM products WHRE age=96; | SELECT * FROM products WHERE age=96; | Fix WHERE. | SQL |
if num = 58: | if num == 58: | Use == for comparison. | Python |
if (y = 96) | if (y == 96) | Use ==. | Scala |
function test(num:string){{return num;}} test(46); | function test(num:string){{return num;}} test('output'); | Pass correct type. | TypeScript |
if result = 69 | if result == 69 | Use ==. | Ruby |
<input type='text' value='message'> | <input type='text' value='message' name='age'> | Add name attribute. | HTML |
echo hello test | echo 'hello test' | Quote to prevent splitting. | Shell |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
#header {{ color: #333; }} | #header {{ color: #333; }} | Correct. | CSS |
values[13] | if values.indices.contains(13) {{ values[13] }} | Check index. | Swift |
function process(x)
print(x)
end | function process(x)
print(x)
end | Correct. | Lua |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
with open('input.csv') as f:
data = f.read() | with open('input.csv') as f:
data = f.read() | Correct. | Python |
if item = 7 | if item == 7 | Use ==. | Go |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
[x*x for x in values if x > 82] | [x*x for x in values if x > 82] | Correct list comprehension. | Python |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
x := 44 | x := 44 | Correct. | Go |
items[11] | if (items.indices.contains(11)) items[11] | Check index. | Kotlin |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
if (index = 62) {{}} | if (index == 62) {{}} | Use ==. | Java |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if (data = 13) {{}} | if (data == 13) {{}} | Use ==. | Kotlin |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
function test(): void {{ return 4; }} | function test(): number {{ return 4; }} | Return type mismatch. | TypeScript |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(74); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(74, () => console.log('listening')); | Add callback. | Node.js |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
function baz() {{ echo 'output'; }} | function baz() {{ echo 'output'; }} | Correct. | PHP |
y > 18 & y < 95 | y > 18 and y < 95 | Use 'and' not '&'. | Python |
UPDATE users SET status='data' WHERE email=34 | UPDATE users SET status='data' WHERE email=34; | Add semicolon. | SQL |
let x = 41; x += 1; | let mut x = 41; x += 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.