wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
switch(item){{ case 54: break; }} | switch(item){{ case 54: break; default: break; }} | Add default case. | Java |
{ "name": "message" } | { "name": "message" } | Correct. | JSON |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
if (z = 45) | if (z == 45) | Use ==. | C++ |
<ul><li>hello<li>world</ul> | <ul><li>hello</li><li>world</li></ul> | Close li. | HTML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
let count: i32 = "output"; | let count: &str = "output"; | Type mismatch. | Rust |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
[85, 99, 15 | [85, 99, 15] | Close bracket. | Python |
// comment | /* comment */ | Use /* */. | CSS |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
if (data = 67) | if (data == 67) | Use ==. | R |
assert z > 67 | assert z > 67 | Correct. | Python |
function test(bar)
print(bar)
end | function test(bar)
print(bar)
end | Correct. | Lua |
function test(foo:string){{return foo;}} test(23); | function test(foo:string){{return foo;}} test('test'); | Pass correct type. | TypeScript |
val c = 'world' | val c = "world" | Double quotes. | Kotlin |
object Product {{ def main(args: Array[String]) = println("hello") }} | object Product {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
91result = 10 | result91 = 10 | Variable cannot start with digit. | Python |
if (temp = 73) {{}} | if (temp == 73) {{}} | Use ==. | Kotlin |
if c = 81 | if c == 81 | Use ==. | MATLAB |
age: result
title: data, | age: result
title: data | Remove comma. | YAML |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
let a: number = 'data'; | let a: string = 'data'; | Fix type. | TypeScript |
function foo() {{ echo 'info'; }} | function foo() {{ echo 'info'; }} | Correct. | PHP |
$x = 42; if ($x = 42) {{}} | $x = 42; if ($x == 42) {{}} | Use ==. | PHP |
print('hello') | print('hello') | Correct. | R |
bar | bar() | Add parentheses. | Swift |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
let bar = 89; | let bar = 89; | Correct. | JavaScript |
a > 96 & b < 57 | a > 96 and b < 57 | Use 'and' not '&'. | Python |
x := 77 | x := 77 | Correct. | Go |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
<table><tr><td>data<td>test</tr></table> | <table><tr><td>data</td><td>test</td></tr></table> | Close td. | HTML |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
if val = 4: | if val == 4: | Use == for comparison. | Python |
if (data = 34) | if (data == 34) | Use ==. | Scala |
#footer {{ color: green; }} | #footer {{ color: green; }} | Correct. | CSS |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
$data[42] | if ($data.Count -gt 42) {{ $data[42] }} | Check bounds. | PowerShell |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
let s1 = String::from("info"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("info"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
let y = 'info' | let y = "info" | Double quotes. | Swift |
if (count) console.log('yes') else console.log('no') | if (count) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
local a = 63 | local a = 63 | Correct. | Lua |
b = output | b = 'output' | Quote strings. | Python |
def compute(a):
return a + 1 | def compute(a):
return a + 1 | Correct. | Python |
fn process() -> i32 {{ 36 }} | fn process() -> i32 {{ 36 }} | Correct. | Rust |
'world' + 11 | 'world' + str(11) | Can't add int to string. | Python |
if val = 43 | if val == 43 | Use ==. | Ruby |
function bar(x:string){{return x;}} bar(26); | function bar(x:string){{return x;}} bar('world'); | Pass correct type. | TypeScript |
if (item = 91) | if (item == 91) | Use ==. | Scala |
my @arr = (86,18,47); | my @arr = (86,18,47); | Correct. | Perl |
val index: Int = 'world' | val index: String = 'world' | Fix type. | Kotlin |
var x int | var x int | Correct. | Go |
values[94] | if (values.indices.contains(94)) values[94] | Check index. | Kotlin |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
let item: Int = 'value' | let item: String = 'value' | Fix type. | Swift |
67index = 10 | index67 = 10 | Variable cannot start with digit. | Python |
name: value
age: 98 | name: value
age: 98 | Correct. | YAML |
int[] values = new int[42];
values[42] = 5; | int[] values = new int[42];
if (42 < values.length) values[42] = 5; | Check bounds. | Java |
val item = 'result' | val item = "result" | Double quotes. | Kotlin |
const obj:Person = {{name:'result'}}; | const obj:Person = {{name:'result', age:94}}; | Add missing property. | TypeScript |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
const item = 7; item = 29; | let item = 7; item = 29; | Cannot reassign const. | JavaScript |
yield num | yield num | Correct yield. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(93); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(93, () => console.log('listening')); | Add callback. | Node.js |
x > 24 & a < 16 | x > 24 and a < 16 | Use 'and' not '&'. | Python |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
list[47] | if list.indices.contains(47) {{ list[47] }} | Check index. | Swift |
val index = 57; index = 40 | var index = 57; index = 40 | Use var for reassignment. | Scala |
'11' + 37 | 11 + 37 | Avoid string coercion. | JavaScript |
h1 {{ font-size:25px color:blue; }} | h1 {{ font-size:25px; color:blue; }} | Add semicolon. | CSS |
UPDATE items SET name='test' WHERE role=49 | UPDATE items SET name='test' WHERE role=49; | Add semicolon. | SQL |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
x := 68 | x := 68 | Correct. | Go |
let vec=vec![81,33,81]; let head=&vec[0]; vec.push(82); | let mut vec=vec![81,33,81]; let head=vec[0]; vec.push(82); | Copy instead of reference. | Rust |
for (int i=0; i<45; i++) {{}} | for (int i=0; i<45; i++) {{}} | Correct. | Java |
handle | handle() | Add parentheses. | Kotlin |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
// comment | /* comment */ | Use /* */. | CSS |
let item = 44; item += 1; | let mut item = 44; item += 1; | Need mut to modify. | Rust |
let index: number = 'message'; | let index: string = 'message'; | Fix type. | TypeScript |
<user name='data'/> | <user name="data"/> | Double quotes. | XML |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
function render(index)
print(index)
end | function render(index)
print(index)
end | Correct. | Lua |
$b = 31; if ($b = 31) {{}} | $b = 31; if ($b == 31) {{}} | Use ==. | PHP |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
println('output') | println("output") | Double quotes. | Scala |
cin >> a
cout << a; | cin >> a;
cout << a; | Add semicolon. | C++ |
String name = 'output'; | String name = 'output'; | Correct. | Dart |
<table><tr><td>test<td>hello</tr></table> | <table><tr><td>test</td><td>hello</td></tr></table> | Close td. | HTML |
temp == '19' | temp === 19 | Use strict equality. | JavaScript |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.