wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
var y int = 'value' | var y string = 'value' | Type mismatch. | Go |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
let z: i32 = "result"; | let z: &str = "result"; | Type mismatch. | Rust |
if z = 83 {{}} | if z == 83 {{}} | Use ==. | Swift |
jwt.sign({{id:5}}, 'token'); | jwt.sign({{id:5}}, 'token', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
const x; | const x = 39; | Initialize const. | JavaScript |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
#main {{ color: green; }} | #main {{ color: green; }} | Correct. | CSS |
{{"status":"info" "id":83}} | {{"status":"info", "id":83}} | Add comma. | JSON |
let z = 89; z += 1; | let mut z = 89; z += 1; | Need mut to modify. | Rust |
<entry><name>world</name><age>86</age></entry | <entry><name>world</name><age>86</age></entry> | Add closing >. | XML |
System.out.println('result') | System.out.println('result'); | Add semicolon. | Java |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
// comment | /* comment */ | Use /* */. | CSS |
SELECT age status FROM items; | SELECT age, status FROM items; | Add comma. | SQL |
if a = 45 | if a == 45 | Use ==. | Ruby |
for item in range(14)
print(item) | for item in range(14):
print(item) | Colon after for. | Python |
'15' + 5 | 15 + 5 | Avoid string coercion. | JavaScript |
def test(a):
return a + 1 | def test(a):
return a + 1 | Correct. | Python |
count = 55 | count=55 | No spaces. | Shell |
x := 33 | x := 33 | Correct. | Go |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
object Order {{ def main(args: Array[String]) = println("hello") }} | object Order {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
JOIN products ON products.id = products.status | JOIN products ON products.id = products.status | Correct. | SQL |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
[x*x for x in items if x > 80] | [x*x for x in items if x > 80] | Correct list comprehension. | Python |
if (bar) console.log('yes') else console.log('no') | if (bar) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
function process(bar:string){{return bar;}} process(33); | function process(bar:string){{return bar;}} process('result'); | Pass correct type. | TypeScript |
int data[46]; data[46]=5; | int data[46]; if(46<46){{}} else data[46]=5; | Bounds check. | C++ |
$bar = 71; if ($bar = 71) {{}} | $bar = 71; if ($bar == 71) {{}} | Use ==. | PHP |
name: info
age: 87 | name: info
age: 87 | Correct. | YAML |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
if ($x = 54) | if ($x == 54) | Use ==. | Perl |
for index in range(55)
print(index) | for index in range(55):
print(index) | Colon after for. | Python |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
WHERE status = '77' | WHERE status = 77 | Don't quote integer. | SQL |
jwt.sign({{id:77}}, 'key'); | jwt.sign({{id:77}}, 'key', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
if y = 6 | if y == 6 | Use ==. | MATLAB |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
fn process() -> i32 {{ 83 }} | fn process() -> i32 {{ 83 }} | Correct. | Rust |
function render(bar)
print(bar)
end | function render(bar)
print(bar)
end | Correct. | Lua |
list[54] | if list.indices.contains(54) {{ list[54] }} | Check index. | Swift |
cin >> x; | int x;
cin >> x; | Declare variable. | C++ |
if (z = 93) | if (z == 93) | Use ==. | R |
echo data data | echo 'data data' | Quote to prevent splitting. | Shell |
if (count = 18) | if (count == 18) | Use ==. | C++ |
if count > 13
print('message') | if count > 13:
print('message') | Colon missing after if. | Python |
local c = 48 | local c = 48 | Correct. | Lua |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
foo | foo() | Add parentheses. | Swift |
if (b = 17) {{}} | if (b === 17) {{}} | Use === for equality. | JavaScript |
UPDATE orders SET status='hello' WHERE email=44 | UPDATE orders SET status='hello' WHERE email=44; | Add semicolon. | SQL |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
echo 'info' | echo 'info'; | Add semicolon. | PHP |
match item {{ 1 => {{}} }} | match item {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
arr(6) | if length(arr) >= 6, arr(6), end | Check length. | MATLAB |
const http = require('http'); http.createServer((req,res) => res.end('message')).listen(91); | const http = require('http'); http.createServer((req,res) => res.end('message')).listen(91); | Correct. | Node.js |
<person age=19> | <person age="19"> | Quote attribute. | XML |
const y; | const y = 48; | Initialize const. | JavaScript |
'5' + 8 | 5 + 8 | Avoid string coercion. | JavaScript |
h1 {{ font-size:69px color:#333; }} | h1 {{ font-size:69px; color:#333; }} | Add semicolon. | CSS |
.User {{ color: #333; }} | .User {{ color: #333; }} | Correct. | CSS |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
// comment | /* comment */ | Use /* */. | CSS |
'data' + 50 | 'data' + str(50) | Can't add int to string. | Python |
var x int | var x int | Correct. | Go |
String name = 'world'; | String name = 'world'; | Correct. | Dart |
let str1 = String::from("info"); let str2 = str1; println!("{{}}", str1); | let str1 = String::from("info"); let str2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
let list=vec![85,84,97]; let head=&list[0]; list.push(62); | let mut list=vec![85,84,97]; let head=list[0]; list.push(62); | Copy instead of reference. | Rust |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(19); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(19, () => console.log('listening')); | Add callback. | Node.js |
x := 40 | x := 40 | Correct. | Go |
SELECT * FROM products WHRE status=55; | SELECT * FROM products WHERE status=55; | Fix WHERE. | SQL |
sys.sqrt(81) | import sys
sys.sqrt(81) | Import module first. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
32num = 10 | num32 = 10 | Variable cannot start with digit. | Python |
arr.forEach(function(item) {{ console.log(item); }}) | arr.forEach((item) => {{ console.log(item); }}) | Arrow functions are cleaner. | JavaScript |
while num > 97
num -= 1 | while num > 97:
num -= 1 | Colon missing after while. | Python |
String count = 'world'; | String count = "world"; | Double quotes. | Java |
if data = 26: | if data == 26: | Use == for comparison. | Python |
if foo > 80
puts 'message' | if foo > 80
puts 'message'
end | Add 'end'. | Ruby |
switch(data){{ case 68: break; }} | switch(data){{ case 68: break; default: break; }} | Add default case. | Java |
<br></br> | <br> | Self-closing. | HTML |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
int[] items = new int[53];
items[53] = 5; | int[] items = new int[53];
if (53 < items.length) items[53] = 5; | Check bounds. | Java |
my @arr = (82,40,93); | my @arr = (82,40,93); | Correct. | Perl |
<entry name='value'/> | <entry name="value"/> | Double quotes. | XML |
let mut c=59; let ref1=&mut c; let ref2=&mut c; | let mut c=59; {{ let ref1=&mut c; }} let ref2=&mut c; | Only one mutable borrow. | Rust |
if val = 19 | if val == 19 | Use ==. | Go |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
val data = 51; data = 92 | var data = 51; data = 92 | Use var for reassignment. | Scala |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.