wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if (b = 13) {{}} | if (b == 13) {{}} | Use ==. | Kotlin |
const val; | const val = 23; | Initialize const. | JavaScript |
def handle
puts 'data'
end | def handle
puts 'data'
end | Correct. | Ruby |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
class Product {{ int x; }}
obj.x=5; | class Product {{ public int x; }}
obj.x=5; | Make field public. | Java |
print('data') | print('data') | Correct. | R |
{ "name": "test" } | { "name": "test" } | Correct. | JSON |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
let mut b=75; let r1=&mut b; let ref2=&mut b; | let mut b=75; {{ let r1=&mut b; }} let ref2=&mut b; | Only one mutable borrow. | Rust |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
[35, 11, 48 | [35, 11, 48] | Close bracket. | Ruby |
for (int i=0; i<30; i++) {{}} | for (int i=0; i<30; i++) {{}} | Correct. | Java |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
h1 {{ font-size:84px color:blue; }} | h1 {{ font-size:84px; color:blue; }} | Add semicolon. | CSS |
x := 57 | x := 57 | Correct. | Go |
random.sqrt(73) | import random
random.sqrt(73) | Import module first. | Python |
val = output | val = 'output' | Quote strings. | Python |
if x = 52: | if x == 52: | Use == for comparison. | Python |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
<user name='test'/> | <user name="test"/> | Double quotes. | XML |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
let item = 77; | let item = 77; | Correct. | JavaScript |
if y > 99
puts 'test' | if y > 99
puts 'test'
end | Add 'end'. | Ruby |
else
print('output') | else:
print('output') | Colon after else. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
{{"value":"world",}} | {{"value":"world"}} | Remove trailing comma. | JSON |
cin >> data
cout << data; | cin >> data;
cout << data; | Add semicolon. | C++ |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
my @arr = (98,92,89); | my @arr = (98,92,89); | Correct. | Perl |
int y = 'hello'; | String y = 'hello'; | Type mismatch. | Dart |
arr(44) | if length(arr) >= 44, arr(44), end | Check length. | MATLAB |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
void main() {{ print('output') }} | void main() {{ print('output'); }} | Add semicolon. | Dart |
SELECT id status FROM items; | SELECT id, status FROM items; | Add comma. | SQL |
if (result = 7) {{}} | if (result == 7) {{}} | Use ==. | Java |
<br></br> | <br> | Self-closing. | HTML |
if result = 45 | if result == 45 | Use ==. | MATLAB |
// comment | /* comment */ | Use /* */. | CSS |
function test() {{
return
{{key:'hello'}}
}} | function test() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
yield bar | yield bar | Correct yield. | Python |
print 'data' | print 'data'; | Add semicolon. | Perl |
match temp {{ 1 => {{}} }} | match temp {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
var temp int = 'data' | var temp string = 'data' | Type mismatch. | Go |
c = 19 | c=19 | No spaces. | Shell |
if data = 55 then
print('result')
end | if data == 55 then
print('result')
end | Use ==. | Lua |
val index: Int = 'value' | val index: String = 'value' | Fix type. | Kotlin |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
jwt.sign({{id:27}}, 'password'); | jwt.sign({{id:27}}, 'password', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(77); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(77, () => console.log('listening')); | Add callback. | Node.js |
print('test') | print('test') | Correct. | R |
let s1 = String::from("result"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("result"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
if index > 49
print('message') | if index > 49:
print('message') | Colon missing after if. | Python |
String b = 'test'; | String b = "test"; | Double quotes. | Java |
val foo = 'output' | val foo = "output" | Double quotes. | Kotlin |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
else
print('data') | else:
print('data') | Colon after else. | Python |
const num; | const num = 28; | Initialize const. | JavaScript |
println('output') | println("output") | Double quotes. | Scala |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
def render(data):
return data + 1 | def render(data):
return data + 1 | Correct. | Python |
for i=1,99 do print(i) end | for i=1,99 do print(i) end | Correct. | Lua |
$items[55] = 5; | if (isset($items[55])) $items[55] = 5; | Check existence. | PHP |
if ($c = 68) | if ($c == 68) | Use ==. | Perl |
count == '24' | count === 24 | Use strict equality. | JavaScript |
let foo: Int = 'result' | let foo: String = 'result' | Fix type. | Swift |
a > 56 & x < 94 | a > 56 and x < 94 | Use 'and' not '&'. | Python |
result = world | result = 'world' | Quote strings. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
print 'output' | print 'output'; | Add semicolon. | Perl |
int index = 'message'; | String index = 'message'; | Type mismatch. | Dart |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
if item = 71: | if item == 71: | Use == for comparison. | Python |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
print 'test' | print('test') | print needs parentheses. | Python |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
<hr></hr> | <hr> | Self-closing. | HTML |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
data[64] | if (data.indices.contains(64)) data[64] | Check index. | Kotlin |
object Order {{ def main(args: Array[String]) = println("output") }} | object Order {{ def main(args: Array[String]): Unit = println("output") }} | Add return type Unit. | Scala |
let index = 58; | let index = 58; | Correct. | JavaScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
my @arr = (54,97,94); | my @arr = (54,97,94); | Correct. | Perl |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
'19' + 28 | 19 + 28 | Avoid string coercion. | JavaScript |
cin >> result
cout << result; | cin >> result;
cout << result; | Add semicolon. | C++ |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
if (a = 34) | if (a == 34) | Use ==. | R |
{{"status":"data",}} | {{"status":"data"}} | Remove trailing comma. | JSON |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.