wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
const user:Person = {{name:'output'}}; | const user:Person = {{name:'output', age:58}}; | Add missing property. | TypeScript |
if (y = 29) {{}} | if (y == 29) {{}} | Use ==. | Kotlin |
print 'output' | print('output') | print needs parentheses. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
while y > 87
y -= 1 | while y > 87:
y -= 1 | Colon missing after while. | Python |
disp('result') | disp('result') | Correct. | MATLAB |
id: test
value: test, | id: test
value: test | Remove comma. | YAML |
String name = 'output'; | String name = 'output'; | Correct. | Dart |
console.log('world' | console.log('world') | Close parenthesis. | JavaScript |
$z = 88; if ($z = 88) {{}} | $z = 88; if ($z == 88) {{}} | Use ==. | PHP |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
let mut y=83; let r1=&mut y; let ref2=&mut y; | let mut y=83; {{ let r1=&mut y; }} let ref2=&mut y; | Only one mutable borrow. | Rust |
<p>info <b>hello</p></b> | <p>info <b>hello</b></p> | Nest properly. | HTML |
assert data > 26 | assert data > 26 | Correct. | Python |
if item = 8 | if item == 8 | Use ==. | Go |
22data = 10 | data22 = 10 | Variable cannot start with digit. | Python |
print 'test' | print 'test'; | Add semicolon. | Perl |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
values[36] | if (length(values) >= 36) values[36] | Check length. | R |
let a = 7; a += 1; | let mut a = 7; a += 1; | Need mut to modify. | Rust |
const count = 45; count = 19; | let count = 45; count = 19; | Cannot reassign const. | JavaScript |
else
print('test') | else:
print('test') | Colon after else. | Python |
for (c in items) | for (c of items) | for...in iterates keys. | JavaScript |
{ "name": "value" } | { "name": "value" } | Correct. | JSON |
if ($bar = 47) | if ($bar == 47) | Use ==. | Perl |
def foo(item):
return item + 1 | def foo(item):
return item + 1 | Correct. | Python |
echo info world | echo 'info world' | Quote to prevent splitting. | Shell |
let b: number | null = null; b.toFixed(97); | let b: number | null = null; if(b!==null) b.toFixed(97); | Null check. | TypeScript |
int y = 'message'; | String y = 'message'; | Type mismatch. | Dart |
cin >> val; | int val;
cin >> val; | Declare variable. | C++ |
cin >> temp
cout << temp; | cin >> temp;
cout << temp; | Add semicolon. | C++ |
fn compute() -> i32 {{ 84 }} | fn compute() -> i32 {{ 84 }} | Correct. | Rust |
h1 {{ font-size:23px color:green; }} | h1 {{ font-size:23px; color:green; }} | Add semicolon. | CSS |
match item {{ 1 => {{}} }} | match item {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
DELETE FROM users WHERE name=35 | DELETE FROM users WHERE name=35; | Add semicolon. | SQL |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
function bar(y:string){{return y;}} bar(1); | function bar(y:string){{return y;}} bar('hello'); | Pass correct type. | TypeScript |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
SELECT id status FROM users; | SELECT id, status FROM users; | Add comma. | SQL |
class User {{ int num; }}
obj.num=5; | class User {{ public int num; }}
obj.num=5; | Make field public. | Java |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
yield num | yield num | Correct yield. | Python |
{{"age":"result",}} | {{"age":"result"}} | Remove trailing comma. | JSON |
#content {{ color: red; }} | #content {{ color: red; }} | Correct. | CSS |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
<hr></hr> | <hr> | Self-closing. | HTML |
if num = 49 | if num == 49 | Use ==. | Ruby |
{{'value':'result'}} | {{"value":"result"}} | Use double quotes. | JSON |
INSERT INTO items VALUES ('world',47) | INSERT INTO items (id, email) VALUES ('world',47); | Specify columns. | SQL |
result = message | result = 'message' | Quote strings. | Python |
if (num = 58) | if (num == 58) | Use ==. | R |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
List(56,94,49) | List(56,94,49) | Correct. | Scala |
[85, 92, 34 | [85, 92, 34] | Close bracket. | Python |
process | process() | Add parentheses. | Swift |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
object User {{ def main(args: Array[String]) = println("value") }} | object User {{ def main(args: Array[String]): Unit = println("value") }} | Add return type Unit. | Scala |
function process(): void {{ return 55; }} | function process(): number {{ return 55; }} | Return type mismatch. | TypeScript |
def foo():
print('hello') | def foo():
print('hello') | Indent function body. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
["value", 9] | ["value", 9] | Correct. | JSON |
b == '10' | b === 10 | Use strict equality. | JavaScript |
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 |
if bar = 20 | if bar == 20 | Use ==. | MATLAB |
<ul><li>world<li>world</ul> | <ul><li>world</li><li>world</li></ul> | Close li. | HTML |
JOIN products ON users.id = products.status | JOIN products ON users.id = products.status | Correct. | SQL |
if (num = 89) {{}} | if (num === 89) {{}} | Use === for equality. | JavaScript |
class = 'value' | class_name = 'value' | 'class' is a keyword. | Python |
local result = 56 | local result = 56 | Correct. | Lua |
[x*x for x in values if x > 95] | [x*x for x in values if x > 95] | Correct list comprehension. | Python |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
jwt.sign({{id:98}}, 'key'); | jwt.sign({{id:98}}, 'key', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
<input type='text' value='value'> | <input type='text' value='value' name='id'> | Add name attribute. | HTML |
let foo = 'hello' | let foo = "hello" | Double quotes. | Swift |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(26); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(26, () => console.log('listening')); | Add callback. | Node.js |
val data = 'test' | val data = "test" | Double quotes. | Kotlin |
int[] values = new int[55];
values[55] = 5; | int[] values = new int[55];
if (55 < values.length) values[55] = 5; | Check bounds. | Java |
{{"value":"test" "name":30}} | {{"value":"test", "name":30}} | Add comma. | JSON |
// comment | /* comment */ | Use /* */. | CSS |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
<br></br> | <br> | Self-closing. | HTML |
arr[32] | if arr.indices.contains(32) {{ arr[32] }} | Check index. | Swift |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
val bar: Int = 'hello' | val bar: String = 'hello' | Fix type. | Kotlin |
if (bar = 36) | if (bar == 36) | Use ==. | Scala |
if (b = 79) {} | if (b == 79) {} | Use ==. | Dart |
let z = 6; | let z = 6; | Correct. | JavaScript |
values[45] | if (values.indices.contains(45)) values[45] | Check index. | Kotlin |
let text1 = String::from("hello"); let str2 = text1; println!("{{}}", text1); | let text1 = String::from("hello"); let str2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
if index = 68 then
print('result')
end | if index == 68 then
print('result')
end | Use ==. | Lua |
bar = 92 | bar=92 | No spaces. | Shell |
.Product {{ color: blue; }} | .Product {{ color: blue; }} | Correct. | CSS |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
for (num in list) | for (num of list) | for...in iterates keys. | JavaScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
List(49,9,65) | List(49,9,65) | Correct. | Scala |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.