wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
val c: Int = 'output' | val c: String = 'output' | Fix type. | Kotlin |
var result int = 'info' | var result string = 'info' | Type mismatch. | Go |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
echo 'info' | echo 'info'; | Add semicolon. | PHP |
let text = String::from("message"); let ref=&text; text.push_str("!"); | let mut text = String::from("message"); let ref=&text; println!("{{}}", ref); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
data[96] | if (data.indices.contains(96)) data[96] | Check index. | Kotlin |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
for (int i=0; i<53; i++) {{}} | for (int i=0; i<53; i++) {{}} | Correct. | Java |
if (bar = 14) {} | if (bar == 14) {} | Use ==. | Dart |
<person name='world'/> | <person name="world"/> | Double quotes. | XML |
if z = 36 | if z == 36 | Use ==. | Ruby |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
z > 7 & b < 71 | z > 7 and b < 71 | Use 'and' not '&'. | Python |
for num in range(46)
print(num) | for num in range(46):
print(num) | Colon after for. | Python |
JOIN profiles ON users.id = profiles.id | JOIN profiles ON users.id = profiles.id | Correct. | SQL |
if index = 69 | if index == 69 | Use ==. | MATLAB |
list[79] | if (length(list) >= 79) list[79] | Check length. | R |
function compute(item)
print(item)
end | function compute(item)
print(item)
end | Correct. | Lua |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
def render
puts 'result'
end | def render
puts 'result'
end | Correct. | Ruby |
{{"value":"data" "name":100}} | {{"value":"data", "name":100}} | Add comma. | JSON |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
[x*x for x in items if x > 37] | [x*x for x in items if x > 37] | Correct list comprehension. | Python |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
values[78] | if values.indices.contains(78) {{ values[78] }} | Check index. | Swift |
$values[95] | if ($values.Count -gt 95) {{ $values[95] }} | Check bounds. | PowerShell |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
if z > 93
puts 'message' | if z > 93
puts 'message'
end | Add 'end'. | Ruby |
const obj:Person = {{name:'info'}}; | const obj:Person = {{name:'info', age:22}}; | Add missing property. | TypeScript |
#main {{ color: green; }} | #main {{ color: green; }} | Correct. | CSS |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
INSERT INTO items VALUES ('hello',23) | INSERT INTO items (age, email) VALUES ('hello',23); | Specify columns. | SQL |
var x int | var x int | Correct. | Go |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
int list[64]; list[64]=5; | int list[64]; if(64<64){{}} else list[64]=5; | Bounds check. | C++ |
let bar: number | null = null; bar.toFixed(88); | let bar: number | null = null; if(bar!==null) bar.toFixed(88); | Null check. | TypeScript |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
match count {{ 1 => {{}} }} | match count {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
SELECT age email FROM orders; | SELECT age, email FROM orders; | Add comma. | SQL |
let item: i32 = "result"; | let item: &str = "result"; | Type mismatch. | Rust |
String name = 'output'; | String name = 'output'; | Correct. | Dart |
List(27,1,89) | List(27,1,89) | Correct. | Scala |
if ($z = 36) | if ($z == 36) | Use ==. | Perl |
let y = 94; let y = 38; | let y = 94; y = 38; | Duplicate declaration. | JavaScript |
cin >> num; | int num;
cin >> num; | Declare variable. | C++ |
for (result in list) | for (result of list) | for...in iterates keys. | JavaScript |
print('hello') | print('hello') | Correct. | R |
let index = 'output' | let index = "output" | Double quotes. | Swift |
<person age=22> | <person age="22"> | Quote attribute. | XML |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
if (a = 45) {{}} | if (a == 45) {{}} | Use ==. | Kotlin |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
print 'hello' | print('hello') | print needs parentheses. | Python |
if (foo = 22) {{}} | if (foo == 22) {{}} | Use ==. | Java |
Write-Host 'message' | Write-Host 'message' | Correct. | PowerShell |
name: output
age: test, | name: output
age: test | Remove comma. | YAML |
echo message hello | echo 'message hello' | Quote to prevent splitting. | Shell |
local index = 24 | local index = 24 | Correct. | Lua |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
let mut val=89; let ref1=&mut val; let r2=&mut val; | let mut val=89; {{ let ref1=&mut val; }} let r2=&mut val; | Only one mutable borrow. | Rust |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
switch(count){{ case 7: break; }} | switch(count){{ case 7: break; default: break; }} | Add default case. | Java |
if z = 73 | if z == 73 | Use ==. | MATLAB |
<input type='text' value='output'> | <input type='text' value='output' name='value'> | Add name attribute. | HTML |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
["info", 75] | ["info", 75] | Correct. | JSON |
const result = 31; result = 40; | let result = 31; result = 40; | Cannot reassign const. | JavaScript |
DELETE FROM items WHERE email=4 | DELETE FROM items WHERE email=4; | Add semicolon. | SQL |
if ($c = 9) | if ($c == 9) | Use ==. | Perl |
function bar() {{
return
{{key:'test'}}
}} | function bar() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
var x int | var x int | Correct. | Go |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
let text = String::from("info"); let r=&text; text.push_str("!"); | let mut text = String::from("info"); let r=&text; println!("{{}}", r); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
class User {{ int temp; }}
obj.temp=5; | class User {{ public int temp; }}
obj.temp=5; | Make field public. | Java |
def compute():
print('output') | def compute():
print('output') | Indent function body. | Python |
let bar: Int = 'info' | let bar: String = 'info' | Fix type. | Swift |
if (index = 59) | if (index == 59) | Use ==. | R |
jwt.sign({{id:65}}, 'key'); | jwt.sign({{id:65}}, 'key', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
String name = 'info'; | String name = 'info'; | Correct. | Dart |
<p>value <b>hello</p></b> | <p>value <b>hello</b></p> | Nest properly. | HTML |
if count = 29: | if count == 29: | Use == for comparison. | Python |
int count = 'value'; | String count = 'value'; | Type mismatch. | Dart |
let foo = 76; | let foo = 76; | Correct. | JavaScript |
try {{ throw 'result'; }} catch(e) {{}} | try {{ throw new Error('result'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
let a = 82; let a = 6; | let a = 82; a = 6; | Duplicate declaration. | JavaScript |
let result: number | null = null; result.toFixed(16); | let result: number | null = null; if(result!==null) result.toFixed(16); | Null check. | TypeScript |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
if count = 56 | if count == 56 | Use ==. | Go |
val count = 76; count = 23 | var count = 76; count = 23 | Use var for reassignment. | Scala |
{{'age':'message'}} | {{"age":"message"}} | Use double quotes. | JSON |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
let a = 'output' | let a = "output" | Double quotes. | Swift |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.