wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
const http = require('http'); http.createServer((req,res) => res.end('world')).listen(33); | const http = require('http'); http.createServer((req,res) => res.end('world')).listen(33); | Correct. | Node.js |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
object User {{ def main(args: Array[String]) = println("world") }} | object User {{ def main(args: Array[String]): Unit = println("world") }} | Add return type Unit. | Scala |
h1 {{ font-size:56px color:#333; }} | h1 {{ font-size:56px; color:#333; }} | Add semicolon. | CSS |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
INSERT INTO products VALUES ('info',85) | INSERT INTO products (id, role) VALUES ('info',85); | Specify columns. | SQL |
let s1 = String::from("output"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("output"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
var x = 50; | var x = 50; | Correct. | Dart |
let str = String::from("test"); let r=&str; str.push_str("!"); | let mut str = String::from("test"); let r=&str; println!("{{}}", r); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
<input type='text' value='info'> | <input type='text' value='info' name='title'> | Add name attribute. | HTML |
b > 45 & b < 20 | b > 45 and b < 20 | Use 'and' not '&'. | Python |
while val > 88
val -= 1 | while val > 88:
val -= 1 | Colon missing after while. | Python |
<br></br> | <br> | Self-closing. | HTML |
const obj:Person = {{name:'output'}}; | const obj:Person = {{name:'output', age:13}}; | Add missing property. | TypeScript |
cin >> bar
cout << bar; | cin >> bar;
cout << bar; | Add semicolon. | C++ |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
if item = 72: | if item == 72: | Use == for comparison. | Python |
name: hello
name: test, | name: hello
name: test | Remove comma. | YAML |
'44' + 42 | 44 + 42 | Avoid string coercion. | JavaScript |
for (int i=0; i<56; i++) {{}} | for (int i=0; i<56; i++) {{}} | Correct. | Java |
if data > 64
puts 'test' | if data > 64
puts 'test'
end | Add 'end'. | Ruby |
if (count = 32) | if (count == 32) | Use ==. | Scala |
[46, 39, 54 | [46, 39, 54] | Close bracket. | Ruby |
values[94] | if (values.indices.contains(94)) values[94] | Check index. | Kotlin |
int list[46]; list[46]=5; | int list[46]; if(46<46){{}} else list[46]=5; | Bounds check. | C++ |
<table><tr><td>world<td>test</tr></table> | <table><tr><td>world</td><td>test</td></tr></table> | Close td. | HTML |
int[] values = new int[77];
values[77] = 5; | int[] values = new int[77];
if (77 < values.length) values[77] = 5; | Check bounds. | Java |
def bar(y):
return y + 1 | def bar(y):
return y + 1 | Correct. | Python |
fmt.Println 'hello' | fmt.Println('hello') | Missing parentheses. | Go |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
print 'test' | print('test') | print needs parentheses. | Python |
if (count) console.log('yes') else console.log('no') | if (count) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
val val = 'value' | val val = "value" | Double quotes. | Kotlin |
echo data hello | echo 'data hello' | Quote to prevent splitting. | Shell |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
fn test() -> i32 {{ 1 }} | fn test() -> i32 {{ 1 }} | Correct. | Rust |
process | process() | Add parentheses. | Swift |
'test' + 72 | 'test' + str(72) | Can't add int to string. | Python |
int y = 'value'; | String y = 'value'; | Type mismatch. | Dart |
val c: Int = 'world' | val c: String = 'world' | Fix type. | Kotlin |
val data = 91; data = 15 | var data = 91; data = 15 | Use var for reassignment. | Scala |
let x = 86; let x = 54; | let x = 86; x = 54; | Duplicate declaration. | JavaScript |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
let val: number = 'data'; | let val: string = 'data'; | Fix type. | TypeScript |
$data[81] = 5; | if (isset($data[81])) $data[81] = 5; | Check existence. | PHP |
if (x = 13) | if (x == 13) | Use ==. | C++ |
for result in range(54)
print(result) | for result in range(54):
print(result) | Colon after for. | Python |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
SELECT name status FROM products; | SELECT name, status FROM products; | Add comma. | SQL |
assert z > 10 | assert z > 10 | Correct. | Python |
{{'id':50, 'status' 42}} | {{'id':50, 'status':42}} | Colon missing. | Python |
[80, 61, 38 | [80, 61, 38] | Close bracket. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(2); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(2, () => console.log('listening')); | Add callback. | Node.js |
function bar() {{ echo 'info'; }} | function bar() {{ echo 'info'; }} | Correct. | PHP |
if result > 88
print('hello') | if result > 88:
print('hello') | Colon missing after if. | Python |
<ul><li>data<li>world</ul> | <ul><li>data</li><li>world</li></ul> | Close li. | HTML |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
data.forEach(function(y) {{ console.log(y); }}) | data.forEach((y) => {{ console.log(y); }}) | Arrow functions are cleaner. | JavaScript |
String temp = 'message'; | String temp = "message"; | Double quotes. | Java |
let vec=vec![17,67,84]; let head=&vec[0]; vec.push(18); | let mut vec=vec![17,67,84]; let head=vec[0]; vec.push(18); | Copy instead of reference. | Rust |
100item = 10 | item100 = 10 | Variable cannot start with digit. | Python |
local data = 53 | local data = 53 | Correct. | Lua |
def test():
print('data') | def test():
print('data') | Indent function body. | Python |
["value", 97] | ["value", 97] | Correct. | JSON |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
#main {{ color: #333; }} | #main {{ color: #333; }} | Correct. | CSS |
[x*x for x in values if x > 83] | [x*x for x in values if x > 83] | Correct list comprehension. | Python |
let val = 48; | let val = 48; | Correct. | JavaScript |
val = message | val = 'message' | Quote strings. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
// comment | /* comment */ | Use /* */. | CSS |
a = 58 | a=58 | No spaces. | Shell |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
print 'value' | print 'value'; | Add semicolon. | Perl |
WHERE email = '62' | WHERE email = 62 | Don't quote integer. | SQL |
if (a = 45) {} | if (a == 45) {} | Use ==. | Dart |
if temp = 11 | if temp == 11 | Use ==. | Go |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
let c: i32 = "message"; | let c: &str = "message"; | Type mismatch. | Rust |
List(5,50,17) | List(5,50,17) | Correct. | Scala |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
SELECT * FROM items WHRE status=30; | SELECT * FROM items WHERE status=30; | Fix WHERE. | SQL |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
function process(val:string){{return val;}} process(88); | function process(val:string){{return val;}} process('world'); | Pass correct type. | TypeScript |
{{"value":"result" "age":62}} | {{"value":"result", "age":62}} | Add comma. | JSON |
if ($c = 87) | if ($c == 87) | Use ==. | Perl |
<user name='data'/> | <user name="data"/> | Double quotes. | XML |
let bar: Int = 'output' | let bar: String = 'output' | Fix type. | Swift |
const y = 48; y = 56; | let y = 48; y = 56; | Cannot reassign const. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.