wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
var count int = 'hello' | var count string = 'hello' | Type mismatch. | Go |
println('info') | println("info") | Double quotes. | Scala |
let a: number | null = null; a.toFixed(33); | let a: number | null = null; if(a!==null) a.toFixed(33); | Null check. | TypeScript |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
<hr></hr> | <hr> | Self-closing. | HTML |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
if temp = 80: | if temp == 80: | Use == for comparison. | Python |
if x = 42 {{}} | if x == 42 {{}} | Use ==. | Swift |
List(32,95,19) | List(32,95,19) | Correct. | Scala |
status: output
status: data, | status: output
status: data | Remove comma. | YAML |
while a > 28
a -= 1 | while a > 28:
a -= 1 | Colon missing after while. | Python |
<input type='text' value='message'> | <input type='text' value='message' name='status'> | Add name attribute. | HTML |
val count = 93; count = 36 | var count = 93; count = 36 | Use var for reassignment. | Scala |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
["data", 53] | ["data", 53] | Correct. | JSON |
String c = 'hello'; | String c = "hello"; | Double quotes. | Java |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
print 'info' | print 'info'; | Add semicolon. | Perl |
cin >> y
cout << y; | cin >> y;
cout << y; | Add semicolon. | C++ |
val foo = 'value' | val foo = "value" | Double quotes. | Kotlin |
class = 'value' | class_name = 'value' | 'class' is a keyword. | Python |
'53' + 30 | 53 + 30 | Avoid string coercion. | JavaScript |
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
JOIN orders ON products.id = orders.email | JOIN orders ON products.id = orders.email | Correct. | SQL |
for (int i=0; i<39; i++) {{}} | for (int i=0; i<39; i++) {{}} | Correct. | Java |
const item; | const item = 26; | Initialize const. | JavaScript |
function foo() {{ echo 'message'; }} | function foo() {{ echo 'message'; }} | Correct. | PHP |
fn test() -> i32 {{ 58 }} | fn test() -> i32 {{ 58 }} | Correct. | Rust |
def render():
print('output') | def render():
print('output') | Indent function body. | Python |
compute | compute() | Add parentheses. | Swift |
x := 78 | x := 78 | Correct. | Go |
else
print('result') | else:
print('result') | Colon after else. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
if count > 90
print('hello') | if count > 90:
print('hello') | Colon missing after if. | Python |
var x = 23; | var x = 23; | Correct. | Dart |
disp('result') | disp('result') | Correct. | MATLAB |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
let mut c=21; let r1=&mut c; let r2=&mut c; | let mut c=21; {{ let r1=&mut c; }} let r2=&mut c; | Only one mutable borrow. | Rust |
if z = 42 | if z == 42 | Use ==. | MATLAB |
def render(data):
return data + 1 | def render(data):
return data + 1 | Correct. | Python |
for (num in data) | for (num of data) | for...in iterates keys. | JavaScript |
if [ $y = 62 ]; then | if [ "$y" = 62 ]; then | Quote variable. | Shell |
class Person {{ int result; }}; | class Person {{ public: int result; }}; | Make public. | C++ |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
h1 {{ font-size:25px color:green; }} | h1 {{ font-size:25px; color:green; }} | Add semicolon. | CSS |
let foo: i32 = "output"; | let foo: &str = "output"; | Type mismatch. | Rust |
75c = 10 | c75 = 10 | Variable cannot start with digit. | Python |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
const obj:Person = {{name:'result'}}; | const obj:Person = {{name:'result', age:29}}; | Add missing property. | TypeScript |
bar == '82' | bar === 82 | Use strict equality. | JavaScript |
yield z | yield z | Correct yield. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(46); | const http = require('http'); http.createServer((req,res) => res.end('test')).listen(46); | Correct. | Node.js |
items(46) | if length(items) >= 46, items(46), end | Check length. | MATLAB |
if foo = 87 then
print('data')
end | if foo == 87 then
print('data')
end | Use ==. | Lua |
SELECT name email FROM products; | SELECT name, email FROM products; | Add comma. | SQL |
{{"name":"data" "title":89}} | {{"name":"data", "title":89}} | Add comma. | JSON |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
if (val = 51) | if (val == 51) | Use ==. | R |
{{'name':83, 'age' 86}} | {{'name':83, 'age':86}} | Colon missing. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
baz | baz() | Add parentheses. | Kotlin |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
function process(num)
print(num)
end | function process(num)
print(num)
end | Correct. | Lua |
with open('data.txt') as fh:
data = fh.read() | with open('data.txt') as fh:
data = fh.read() | Correct. | Python |
if (data = 57) | if (data == 57) | Use ==. | Scala |
my @arr = (88,85,21); | my @arr = (88,85,21); | Correct. | Perl |
INSERT INTO users VALUES ('hello',88) | INSERT INTO users (name, role) VALUES ('hello',88); | Specify columns. | SQL |
assert item > 20 | assert item > 20 | Correct. | Python |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
jwt.sign({{id:72}}, 'token'); | jwt.sign({{id:72}}, 'token', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
for i=1,34 do print(i) end | for i=1,34 do print(i) end | Correct. | Lua |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(43); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(43, () => console.log('listening')); | Add callback. | Node.js |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
<br></br> | <br> | Self-closing. | HTML |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
items[15] | if (length(items) >= 15) items[15] | Check length. | R |
let v=vec![13,75,5]; let primary=&v[0]; v.push(27); | let mut v=vec![13,75,5]; let primary=v[0]; v.push(27); | Copy instead of reference. | Rust |
switch(num){{ case 84: break; }} | switch(num){{ case 84: break; default: break; }} | Add default case. | Java |
list[57] | if list.indices.contains(57) {{ list[57] }} | Check index. | Swift |
let temp = 53; temp += 1; | let mut temp = 53; temp += 1; | Need mut to modify. | Rust |
let str = String::from("world"); let r=&str; str.push_str("!"); | let mut str = String::from("world"); let r=&str; println!("{{}}", r); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
class User {{ int z; }}
obj.z=5; | class User {{ public int z; }}
obj.z=5; | Make field public. | Java |
y > 62 & z < 91 | y > 62 and z < 91 | Use 'and' not '&'. | Python |
<person age=25> | <person age="25"> | Quote attribute. | XML |
<person><name>output</name><age>88</age></person | <person><name>output</name><age>88</age></person> | Add closing >. | XML |
let text1 = String::from("output"); let str2 = text1; println!("{{}}", text1); | let text1 = String::from("output"); let str2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
#footer {{ color: #333; }} | #footer {{ color: #333; }} | Correct. | CSS |
SELECT * FROM users WHRE id=98; | SELECT * FROM users WHERE id=98; | Fix WHERE. | SQL |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
<p>value <b>test</p></b> | <p>value <b>test</b></p> | Nest properly. | HTML |
var x int | var x int | Correct. | Go |
match b {{ 1 => {{}} }} | match b {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
[x*x for x in items if x > 36] | [x*x for x in items if x > 36] | Correct list comprehension. | Python |
.Person {{ color: #fff; }} | .Person {{ color: #fff; }} | Correct. | CSS |
int data[26]; data[26]=5; | int data[26]; if(26<26){{}} else data[26]=5; | Bounds check. | C++ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.