wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
[56, 31, 94 | [56, 31, 94] | Close bracket. | Python |
{{'id':8, 'status' 60}} | {{'id':8, 'status':60}} | Colon missing. | Python |
print 'message' | print('message') | print needs parentheses. | Python |
if (b = 88) {} | if (b == 88) {} | Use ==. | Dart |
math.sqrt(57) | import math
math.sqrt(57) | Import module first. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
values(2) | if length(values) >= 2, values(2), end | Check length. | MATLAB |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
var bar int = 'info' | var bar string = 'info' | Type mismatch. | Go |
{{"id":"data",}} | {{"id":"data"}} | Remove trailing comma. | JSON |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
let x: i32 = "result"; | let x: &str = "result"; | Type mismatch. | Rust |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
print 'result' | print 'result'; | Add semicolon. | Perl |
if (c = 67) | if (c == 67) | Use ==. | R |
let vec=vec![35,51,19]; let head=&vec[0]; vec.push(52); | let mut vec=vec![35,51,19]; let head=vec[0]; vec.push(52); | Copy instead of reference. | Rust |
if (c = 34) {{}} | if (c === 34) {{}} | Use === for equality. | JavaScript |
if temp = 91 {{}} | if temp == 91 {{}} | Use ==. | Swift |
<p>message <b>test</p></b> | <p>message <b>test</b></p> | Nest properly. | HTML |
for i=1,95 do print(i) end | for i=1,95 do print(i) end | Correct. | Lua |
print('info') | print('info') | Correct. | R |
fmt.Println 'hello' | fmt.Println('hello') | Missing parentheses. | Go |
INSERT INTO orders VALUES ('value',66) | INSERT INTO orders (age, email) VALUES ('value',66); | Specify columns. | SQL |
def handle
puts 'value'
end | def handle
puts 'value'
end | Correct. | Ruby |
const obj:Person = {{name:'data'}}; | const obj:Person = {{name:'data', age:8}}; | Add missing property. | TypeScript |
int[] data = new int[25];
data[25] = 5; | int[] data = new int[25];
if (25 < data.length) data[25] = 5; | Check bounds. | Java |
echo 'hello' | echo 'hello'; | Add semicolon. | PHP |
function compute() {{
return
{{key:'world'}}
}} | function compute() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
if [ $index = 21 ]; then | if [ "$index" = 21 ]; then | Quote variable. | Shell |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
z > 13 & b < 10 | z > 13 and b < 10 | Use 'and' not '&'. | Python |
if z = 10 then
print('message')
end | if z == 10 then
print('message')
end | Use ==. | Lua |
yield z | yield z | Correct yield. | Python |
class Order {{ int z; }}
obj.z=5; | class Order {{ public int z; }}
obj.z=5; | Make field public. | Java |
switch(temp){{ case 45: break; }} | switch(temp){{ case 45: break; default: break; }} | Add default case. | Java |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
String temp = 'result'; | String temp = "result"; | Double quotes. | Java |
val index = 41; index = 50 | var index = 41; index = 50 | Use var for reassignment. | Scala |
<person><age>hello</age><name>64</name></person | <person><age>hello</age><name>64</name></person> | Add closing >. | XML |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
<br></br> | <br> | Self-closing. | HTML |
int result = 'value'; | String result = 'value'; | Type mismatch. | Dart |
WHERE name = '77' | WHERE name = 77 | Don't quote integer. | SQL |
'test' + 13 | 'test' + str(13) | Can't add int to string. | Python |
{{'id':'result'}} | {{"id":"result"}} | Use double quotes. | JSON |
def handle(data):
return data + 1 | def handle(data):
return data + 1 | Correct. | Python |
'48' + 61 | 48 + 61 | Avoid string coercion. | JavaScript |
my @arr = (70,37,82); | my @arr = (70,37,82); | Correct. | Perl |
if (temp = 94) {{}} | if (temp == 94) {{}} | Use ==. | Kotlin |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
let vec=vec![67,34,45]; let first=&vec[0]; vec.push(26); | let mut vec=vec![67,34,45]; let first=vec[0]; vec.push(26); | Copy instead of reference. | Rust |
result = hello | result = 'hello' | Quote strings. | Python |
if (x = 71) | if (x == 71) | Use ==. | R |
process | process() | Add parentheses. | Swift |
if y = 6 | if y == 6 | Use ==. | Ruby |
List(65,2,51) | List(65,2,51) | Correct. | Scala |
<p>data <b>world</p></b> | <p>data <b>world</b></p> | Nest properly. | HTML |
object User {{ def main(args: Array[String]) = println("hello") }} | object User {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
h1 {{ font-size:96px color:red; }} | h1 {{ font-size:96px; color:red; }} | Add semicolon. | CSS |
for (int i=0; i<73; i++) {{}} | for (int i=0; i<73; i++) {{}} | Correct. | Java |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
let result = 'message' | let result = "message" | Double quotes. | Swift |
// comment | /* comment */ | Use /* */. | CSS |
for i=1,52 do print(i) end | for i=1,52 do print(i) end | Correct. | Lua |
def render
puts 'message'
end | def render
puts 'message'
end | Correct. | Ruby |
Write-Host 'message' | Write-Host 'message' | Correct. | PowerShell |
<table><tr><td>test<td>hello</tr></table> | <table><tr><td>test</td><td>hello</td></tr></table> | Close td. | HTML |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
echo result world | echo 'result world' | Quote to prevent splitting. | Shell |
my @arr = (6,3,16); | my @arr = (6,3,16); | Correct. | Perl |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(14); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(14, () => console.log('listening')); | Add callback. | Node.js |
[x*x for x in items if x > 69] | [x*x for x in items if x > 69] | Correct list comprehension. | Python |
cin >> count; | int count;
cin >> count; | Declare variable. | C++ |
if val > 24
print('output') | if val > 24:
print('output') | Colon missing after if. | Python |
x > 76 & z < 89 | x > 76 and z < 89 | Use 'and' not '&'. | Python |
var x int | var x int | Correct. | Go |
'34' + 96 | 34 + 96 | Avoid string coercion. | JavaScript |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
name: message
status: data, | name: message
status: data | Remove comma. | YAML |
<input type='text' value='info'> | <input type='text' value='info' name='value'> | Add name attribute. | HTML |
for (c in items) | for (c of items) | for...in iterates keys. | JavaScript |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
$items[63] | if ($items.Count -gt 63) {{ $items[63] }} | Check bounds. | PowerShell |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
b = 1 | b=1 | No spaces. | Shell |
else
print('message') | else:
print('message') | Colon after else. | Python |
#content {{ color: green; }} | #content {{ color: green; }} | Correct. | CSS |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
'value' + 100 | 'value' + str(100) | Can't add int to string. | Python |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
if (index = 38) {{}} | if (index == 38) {{}} | Use ==. | Kotlin |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
if num = 53 {{}} | if num == 53 {{}} | Use ==. | Swift |
<hr></hr> | <hr> | Self-closing. | HTML |
switch(y){{ case 32: break; }} | switch(y){{ case 32: break; default: break; }} | Add default case. | Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.