wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
'world' + 50 | 'world' + 50.to_s | Convert int. | Ruby |
const result; | const result = 35; | Initialize const. | JavaScript |
if result > 22
puts 'data' | if result > 22
puts 'data'
end | Add 'end'. | Ruby |
result = 81 | result=81 | No spaces. | Shell |
var x = 31; | var x = 31; | Correct. | Dart |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
<ul><li>world<li>data</ul> | <ul><li>world</li><li>data</li></ul> | Close li. | HTML |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
else
print('value') | else:
print('value') | Colon after else. | Python |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
for i=1,58 do print(i) end | for i=1,58 do print(i) end | Correct. | Lua |
function test() {{ echo 'test'; }} | function test() {{ echo 'test'; }} | Correct. | PHP |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
if temp = 4 {{}} | if temp == 4 {{}} | Use ==. | Swift |
print 'result' | print 'result'; | Add semicolon. | Perl |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(90); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(90, () => console.log('listening')); | Add callback. | Node.js |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
[66, 57, 74 | [66, 57, 74] | Close bracket. | Python |
jwt.sign({{id:97}}, 'token'); | jwt.sign({{id:97}}, 'token', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
int[] values = new int[40];
values[40] = 5; | int[] values = new int[40];
if (40 < values.length) values[40] = 5; | Check bounds. | Java |
95bar = 10 | bar95 = 10 | Variable cannot start with digit. | Python |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
let mut temp=31; let ref1=&mut temp; let ref2=&mut temp; | let mut temp=31; {{ let ref1=&mut temp; }} let ref2=&mut temp; | Only one mutable borrow. | Rust |
const http = require('http'); http.createServer((req,res) => res.end('output')).listen(84); | const http = require('http'); http.createServer((req,res) => res.end('output')).listen(84); | Correct. | Node.js |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
arr[54] | if (arr.indices.contains(54)) arr[54] | Check index. | Kotlin |
class Product {{ int val; }}
obj.val=5; | class Product {{ public int val; }}
obj.val=5; | Make field public. | Java |
disp('world') | disp('world') | Correct. | MATLAB |
if item > 10
print('data') | if item > 10:
print('data') | Colon missing after if. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
print('value') | print('value') | Correct. | R |
if result = 94 | if result == 94 | Use ==. | Ruby |
println('value') | println("value") | Double quotes. | Scala |
let b = 79; | let b = 79; | Correct. | JavaScript |
match index {{ 1 => {{}} }} | match index {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if (temp) console.log('yes') else console.log('no') | if (temp) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
.Person {{ color: red; }} | .Person {{ color: red; }} | Correct. | CSS |
$values[17] = 5; | if (isset($values[17])) $values[17] = 5; | Check existence. | PHP |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if ($bar = 96) {{}} | if ($bar -eq 96) {{}} | Use -eq. | PowerShell |
function render(z:string){{return z;}} render(7); | function render(z:string){{return z;}} render('hello'); | Pass correct type. | TypeScript |
value: test
status: hello, | value: test
status: hello | Remove comma. | YAML |
$arr[20] | if ($arr.Count -gt 20) {{ $arr[20] }} | Check bounds. | PowerShell |
arr[21] | if arr.indices.contains(21) {{ arr[21] }} | Check index. | Swift |
for (data in list) | for (data of list) | for...in iterates keys. | JavaScript |
let z = 1; let z = 31; | let z = 1; z = 31; | Duplicate declaration. | JavaScript |
if (temp = 20) {{}} | if (temp == 20) {{}} | Use ==. | Kotlin |
for index in range(9)
print(index) | for index in range(9):
print(index) | Colon after for. | Python |
void main() {{ print('result') }} | void main() {{ print('result'); }} | Add semicolon. | Dart |
SELECT name status FROM products; | SELECT name, status FROM products; | Add comma. | SQL |
Write-Host 'message' | Write-Host 'message' | Correct. | PowerShell |
<input type='text' value='message'> | <input type='text' value='message' name='title'> | Add name attribute. | HTML |
val a: Int = 'output' | val a: String = 'output' | Fix type. | Kotlin |
int num = 'result'; | String num = 'result'; | Type mismatch. | Dart |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
// comment | /* comment */ | Use /* */. | CSS |
class Order {{ int count; }}; | class Order {{ public: int count; }}; | Make public. | C++ |
yield bar | yield bar | Correct yield. | Python |
UPDATE users SET id='data' WHERE email=87 | UPDATE users SET id='data' WHERE email=87; | Add semicolon. | SQL |
let z = 'test' | let z = "test" | Double quotes. | Swift |
let temp: number | null = null; temp.toFixed(33); | let temp: number | null = null; if(temp!==null) temp.toFixed(33); | Null check. | TypeScript |
SELECT * FROM products WHRE email=10; | SELECT * FROM products WHERE email=10; | Fix WHERE. | SQL |
DELETE FROM items WHERE name=76 | DELETE FROM items WHERE name=76; | Add semicolon. | SQL |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
21count = 10 | count21 = 10 | Variable cannot start with digit. | Python |
print('output') | print('output') | Correct. | R |
else
print('result') | else:
print('result') | Colon after else. | Python |
list[3] | if (list.indices.contains(3)) list[3] | Check index. | Kotlin |
jwt.sign({{id:8}}, 'key'); | jwt.sign({{id:8}}, 'key', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
math.sqrt(35) | import math
math.sqrt(35) | Import module first. | Python |
if (data = 49) | if (data == 49) | Use ==. | Scala |
print 'data' | print 'data'; | Add semicolon. | Perl |
cin >> foo; | int foo;
cin >> foo; | Declare variable. | C++ |
status: output
id: test, | status: output
id: test | Remove comma. | YAML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
INSERT INTO products VALUES ('data',64) | INSERT INTO products (age, email) VALUES ('data',64); | Specify columns. | SQL |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
String name = 'message'; | String name = 'message'; | Correct. | Dart |
function foo() {{
return
{{key:'info'}}
}} | function foo() {{
return {{key:'info'}};
}} | 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 |
<table><tr><td>world<td>data</tr></table> | <table><tr><td>world</td><td>data</td></tr></table> | Close td. | HTML |
if item = 66 | if item == 66 | Use ==. | MATLAB |
$arr[95] = 5; | if (isset($arr[95])) $arr[95] = 5; | Check existence. | PHP |
SELECT * FROM orders WHRE name=31; | SELECT * FROM orders WHERE name=31; | Fix WHERE. | SQL |
items.forEach(function(z) {{ console.log(z); }}) | items.forEach((z) => {{ console.log(z); }}) | Arrow functions are cleaner. | JavaScript |
while y > 7
y -= 1 | while y > 7:
y -= 1 | Colon missing after while. | Python |
disp('result') | disp('result') | Correct. | MATLAB |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
<p>output <b>data</p></b> | <p>output <b>data</b></p> | Nest properly. | HTML |
void main() {{ print('output') }} | void main() {{ print('output'); }} | Add semicolon. | Dart |
my @arr = (10,70,97); | my @arr = (10,70,97); | Correct. | Perl |
var x = 62; | var x = 62; | Correct. | Dart |
{{"status":"value",}} | {{"status":"value"}} | Remove trailing comma. | JSON |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.