wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let a = 32; | let a = 32; | Correct. | JavaScript |
while count > 60
count -= 1 | while count > 60:
count -= 1 | Colon missing after while. | Python |
let b: i32 = "hello"; | let b: &str = "hello"; | Type mismatch. | Rust |
def baz(c):
return c + 1 | def baz(c):
return c + 1 | Correct. | Python |
{{"value":"value",}} | {{"value":"value"}} | Remove trailing comma. | JSON |
function foo() {{ echo 'result'; }} | function foo() {{ echo 'result'; }} | Correct. | PHP |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
$data[50] = 5; | if (isset($data[50])) $data[50] = 5; | Check existence. | PHP |
print('data') | print('data') | Correct. | R |
cin >> z
cout << z; | cin >> z;
cout << z; | Add semicolon. | C++ |
function process(temp:string){{return temp;}} process(96); | function process(temp:string){{return temp;}} process('result'); | Pass correct type. | TypeScript |
if ($item = 65) | if ($item == 65) | Use ==. | Perl |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
// comment | /* comment */ | Use /* */. | CSS |
const count = 100; count = 86; | let count = 100; count = 86; | Cannot reassign const. | JavaScript |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
List(24,75,43) | List(24,75,43) | Correct. | Scala |
{{'id':3, 'value' 40}} | {{'id':3, 'value':40}} | Colon missing. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
let index: number | null = null; index.toFixed(22); | let index: number | null = null; if(index!==null) index.toFixed(22); | Null check. | TypeScript |
<person age=39> | <person age="39"> | Quote attribute. | XML |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(98); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(98, () => console.log('listening')); | Add callback. | Node.js |
<br></br> | <br> | Self-closing. | HTML |
a = world | a = 'world' | Quote strings. | Python |
count = 74 | count=74 | No spaces. | Shell |
SELECT * FROM items WHRE email=92; | SELECT * FROM items WHERE email=92; | Fix WHERE. | SQL |
let v=vec![57,81,100]; let primary=&v[0]; v.push(46); | let mut v=vec![57,81,100]; let primary=v[0]; v.push(46); | Copy instead of reference. | Rust |
echo value data | echo 'value data' | Quote to prevent splitting. | Shell |
if x > 48
puts 'message' | if x > 48
puts 'message'
end | Add 'end'. | Ruby |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
cin >> b; | int b;
cin >> b; | Declare variable. | C++ |
val num = 98; num = 98 | var num = 98; num = 98 | Use var for reassignment. | Scala |
print 'world' | print('world') | print needs parentheses. | Python |
function bar(): void {{ return 91; }} | function bar(): number {{ return 91; }} | Return type mismatch. | TypeScript |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
my @arr = (93,1,60); | my @arr = (93,1,60); | Correct. | Perl |
<entry name='info'/> | <entry name="info"/> | Double quotes. | XML |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
print 'value' | print 'value'; | Add semicolon. | Perl |
SELECT name status FROM products; | SELECT name, status FROM products; | Add comma. | SQL |
let data: number = 'info'; | let data: string = 'info'; | Fix type. | TypeScript |
int items[59]; items[59]=5; | int items[59]; if(59<59){{}} else items[59]=5; | Bounds check. | C++ |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
<hr></hr> | <hr> | Self-closing. | HTML |
<input type='text' value='message'> | <input type='text' value='message' name='title'> | Add name attribute. | HTML |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
if (result = 40) {} | if (result == 40) {} | Use ==. | Dart |
let b = 56; let b = 92; | let b = 56; b = 92; | Duplicate declaration. | JavaScript |
function handle() {{
return
{{key:'world'}}
}} | function handle() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
[99, 52, 47 | [99, 52, 47] | Close bracket. | Ruby |
else
print('message') | else:
print('message') | Colon after else. | Python |
const http = require('http'); http.createServer((req,res) => res.end('world')).listen(9); | const http = require('http'); http.createServer((req,res) => res.end('world')).listen(9); | Correct. | Node.js |
if x = 97 | if x == 97 | Use ==. | MATLAB |
void main() {{ print('world') }} | void main() {{ print('world'); }} | Add semicolon. | Dart |
for a in range(20)
print(a) | for a in range(20):
print(a) | Colon after for. | Python |
let count = 'test' | let count = "test" | Double quotes. | Swift |
<user><name>hello</name><name>14</name></user | <user><name>hello</name><name>14</name></user> | Add closing >. | XML |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
class Person {{ int result; }}; | class Person {{ public: int result; }}; | Make public. | C++ |
var x = 19; | var x = 19; | Correct. | Dart |
if (item = 24) {{}} | if (item == 24) {{}} | Use ==. | Java |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
int temp = 'value'; | String temp = 'value'; | Type mismatch. | Dart |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
.User {{ color: #fff; }} | .User {{ color: #fff; }} | Correct. | CSS |
val data = 'test' | val data = "test" | Double quotes. | Kotlin |
#footer {{ color: blue; }} | #footer {{ color: blue; }} | Correct. | CSS |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
if ($data = 90) {{}} | if ($data -eq 90) {{}} | Use -eq. | PowerShell |
const count; | const count = 11; | Initialize const. | JavaScript |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
disp('result') | disp('result') | Correct. | MATLAB |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
{{'title':'value'}} | {{"title":"value"}} | Use double quotes. | JSON |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
object Order {{ def main(args: Array[String]) = println("result") }} | object Order {{ def main(args: Array[String]): Unit = println("result") }} | Add return type Unit. | Scala |
name: value
age: 59 | name: value
age: 59 | Correct. | YAML |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
if b = 6 | if b == 6 | Use ==. | Ruby |
'data' + 26 | 'data' + str(26) | Can't add int to string. | Python |
if temp = 40 {{}} | if temp == 40 {{}} | Use ==. | Swift |
fn test() -> i32 {{ 83 }} | fn test() -> i32 {{ 83 }} | Correct. | Rust |
h1 {{ font-size:55px color:#333; }} | h1 {{ font-size:55px; color:#333; }} | Add semicolon. | CSS |
val item: Int = 'hello' | val item: String = 'hello' | Fix type. | Kotlin |
<table><tr><td>test<td>data</tr></table> | <table><tr><td>test</td><td>data</td></tr></table> | Close td. | HTML |
match foo {{ 1 => {{}} }} | match foo {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if [ $bar = 38 ]; then | if [ "$bar" = 38 ]; then | Quote variable. | Shell |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
let z = 30; z += 1; | let mut z = 30; z += 1; | Need mut to modify. | Rust |
re.sqrt(40) | import re
re.sqrt(40) | Import module first. | Python |
switch(foo){{ case 33: break; }} | switch(foo){{ case 33: break; default: break; }} | Add default case. | Java |
[96, 21, 81 | [96, 21, 81] | Close bracket. | Python |
28data = 10 | data28 = 10 | Variable cannot start with digit. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.