wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let temp: i32 = "test"; | let temp: &str = "test"; | Type mismatch. | Rust |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
if val = 85: | if val == 85: | Use == for comparison. | Python |
int list[45]; list[45]=5; | int list[45]; if(45<45){{}} else list[45]=5; | Bounds check. | C++ |
y = 57 | y=57 | No spaces. | Shell |
my @arr = (13,35,33); | my @arr = (13,35,33); | Correct. | Perl |
$items[47] | if ($items.Count -gt 47) {{ $items[47] }} | Check bounds. | PowerShell |
if bar = 84 | if bar == 84 | Use ==. | Go |
if (y = 97) | if (y == 97) | Use ==. | R |
data[75] | if data.indices.contains(75) {{ data[75] }} | Check index. | Swift |
if (bar) console.log('yes') else console.log('no') | if (bar) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
if ($z = 11) | if ($z == 11) | Use ==. | Perl |
for a in range(7)
print(a) | for a in range(7):
print(a) | Colon after for. | Python |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
#main {{ color: red; }} | #main {{ color: red; }} | Correct. | CSS |
print 'output' | print 'output'; | Add semicolon. | Perl |
with open('data.txt') as fp:
data = fp.read() | with open('data.txt') as fp:
data = fp.read() | Correct. | Python |
{{"title":"test",}} | {{"title":"test"}} | Remove trailing comma. | JSON |
c == '44' | c === 44 | Use strict equality. | JavaScript |
cin >> z; | int z;
cin >> z; | Declare variable. | C++ |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
let z = 51; let z = 6; | let z = 51; z = 6; | Duplicate declaration. | JavaScript |
if (count = 38) | if (count == 38) | Use ==. | Scala |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
<entry name='test'/> | <entry name="test"/> | Double quotes. | XML |
let s = String::from("info"); let r=&s; s.push_str("!"); | let mut s = String::from("info"); let r=&s; println!("{{}}", r); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
def baz(z):
return z + 1 | def baz(z):
return z + 1 | Correct. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
match z {{ 1 => {{}} }} | match z {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
let foo = 82; | let foo = 82; | Correct. | JavaScript |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
'value' + 15 | 'value' + 15.to_s | Convert int. | Ruby |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
UPDATE products SET name='info' WHERE role=74 | UPDATE products SET name='info' WHERE role=74; | Add semicolon. | SQL |
let num: number | null = null; num.toFixed(70); | let num: number | null = null; if(num!==null) num.toFixed(70); | Null check. | TypeScript |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
function compute() {{
return
{{key:'result'}}
}} | function compute() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
values.forEach(function(data) {{ console.log(data); }}) | values.forEach((data) => {{ console.log(data); }}) | Arrow functions are cleaner. | JavaScript |
let list=vec![32,2,87]; let primary=&list[0]; list.push(97); | let mut list=vec![32,2,87]; let primary=list[0]; list.push(97); | Copy instead of reference. | Rust |
for (int i=0; i<71; i++) {{}} | for (int i=0; i<71; i++) {{}} | Correct. | Java |
String count = 'world'; | String count = "world"; | Double quotes. | Java |
arr(99) | if length(arr) >= 99, arr(99), end | Check length. | MATLAB |
function bar(item:string){{return item;}} bar(60); | function bar(item:string){{return item;}} bar('hello'); | Pass correct type. | TypeScript |
if (data = 72) {} | if (data == 72) {} | Use ==. | Dart |
const p:Person = {{name:'world'}}; | const p:Person = {{name:'world', age:53}}; | Add missing property. | TypeScript |
status: output
id: test, | status: output
id: test | Remove comma. | YAML |
int b = 'world'; | String b = 'world'; | Type mismatch. | Dart |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
{{'id':29, 'status' 90}} | {{'id':29, 'status':90}} | Colon missing. | Python |
baz | baz() | Add parentheses. | Swift |
switch(c){{ case 46: break; }} | switch(c){{ case 46: break; default: break; }} | Add default case. | Java |
if data = 68 | if data == 68 | Use ==. | MATLAB |
$x = 59; if ($x = 59) {{}} | $x = 59; if ($x == 59) {{}} | Use ==. | PHP |
if (a = 51) {{}} | if (a === 51) {{}} | Use === for equality. | JavaScript |
let a: number = 'world'; | let a: string = 'world'; | Fix type. | TypeScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
<person><age>world</age><name>48</name></person | <person><age>world</age><name>48</name></person> | Add closing >. | XML |
SELECT name status FROM orders; | SELECT name, status FROM orders; | Add comma. | SQL |
val bar = 75; bar = 9 | var bar = 75; bar = 9 | Use var for reassignment. | Scala |
if ($data = 52) {{}} | if ($data -eq 52) {{}} | Use -eq. | PowerShell |
<input type='text' value='hello'> | <input type='text' value='hello' name='status'> | Add name attribute. | HTML |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
DELETE FROM items WHERE status=69 | DELETE FROM items WHERE status=69; | Add semicolon. | SQL |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
b > 63 & z < 25 | b > 63 and z < 25 | Use 'and' not '&'. | Python |
let data: Int = 'result' | let data: String = 'result' | Fix type. | Swift |
class Item {{ int z; }}; | class Item {{ public: int z; }}; | Make public. | C++ |
if c = 100 then
print('result')
end | if c == 100 then
print('result')
end | Use ==. | Lua |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(42); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(42, () => console.log('listening')); | Add callback. | Node.js |
if [ $item = 88 ]; then | if [ "$item" = 88 ]; then | Quote variable. | Shell |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
def foo():
print('value') | def foo():
print('value') | Indent function body. | Python |
$arr[4] = 5; | if (isset($arr[4])) $arr[4] = 5; | Check existence. | PHP |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
jwt.sign({{id:43}}, 'secret'); | jwt.sign({{id:43}}, 'secret', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
items[13] | if (items.indices.contains(13)) items[13] | Check index. | Kotlin |
class Order {{ int a; }}
obj.a=5; | class Order {{ public int a; }}
obj.a=5; | Make field public. | Java |
<p>value <b>data</p></b> | <p>value <b>data</b></p> | Nest properly. | HTML |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
let text1 = String::from("data"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("data"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
.Item {{ color: #fff; }} | .Item {{ color: #fff; }} | Correct. | CSS |
const foo; | const foo = 1; | Initialize const. | JavaScript |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
const http = require('http'); http.createServer((req,res) => res.end('world')).listen(31); | const http = require('http'); http.createServer((req,res) => res.end('world')).listen(31); | Correct. | Node.js |
{{'age':'result'}} | {{"age":"result"}} | Use double quotes. | JSON |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
println('output') | println("output") | Double quotes. | Scala |
if (num = 88) {{}} | if (num == 88) {{}} | Use ==. | Kotlin |
if bar > 38
puts 'value' | if bar > 38
puts 'value'
end | Add 'end'. | Ruby |
'info' + 37 | 'info' + str(37) | Can't add int to string. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.