wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
JOIN orders ON items.id = orders.status | JOIN orders ON items.id = orders.status | Correct. | SQL |
def handle(foo):
return foo + 1 | def handle(foo):
return foo + 1 | Correct. | Python |
let str = String::from("test"); let borrow=&str; str.push_str("!"); | let mut str = String::from("test"); let borrow=&str; println!("{{}}", borrow); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
{ "name": "world" } | { "name": "world" } | Correct. | JSON |
for i=1,75 do print(i) end | for i=1,75 do print(i) end | Correct. | Lua |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
let data: number = 'message'; | let data: string = 'message'; | Fix type. | TypeScript |
val val: Int = 'value' | val val: String = 'value' | Fix type. | Kotlin |
local y = 15 | local y = 15 | Correct. | Lua |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
def process
puts 'test'
end | def process
puts 'test'
end | Correct. | Ruby |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
disp('test') | disp('test') | Correct. | MATLAB |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
cin >> bar
cout << bar; | cin >> bar;
cout << bar; | Add semicolon. | C++ |
void main() {{ print('message') }} | void main() {{ print('message'); }} | Add semicolon. | Dart |
class Person {{ int val; }}
obj.val=5; | class Person {{ public int val; }}
obj.val=5; | Make field public. | Java |
$a = 89; if ($a = 89) {{}} | $a = 89; if ($a == 89) {{}} | Use ==. | PHP |
cin >> a; | int a;
cin >> a; | Declare variable. | C++ |
if (b = 94) {{}} | if (b == 94) {{}} | Use ==. | Java |
println('test') | println("test") | Double quotes. | Scala |
INSERT INTO orders VALUES ('output',19) | INSERT INTO orders (age, role) VALUES ('output',19); | Specify columns. | SQL |
[51, 42, 31 | [51, 42, 31] | Close bracket. | Python |
if count = 93: | if count == 93: | Use == for comparison. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
while num > 1
num -= 1 | while num > 1:
num -= 1 | Colon missing after while. | Python |
for (y in items) | for (y of items) | for...in iterates keys. | JavaScript |
function compute(num)
print(num)
end | function compute(num)
print(num)
end | Correct. | Lua |
if b = 19 {{}} | if b == 19 {{}} | Use ==. | Swift |
<entry><desc>result</desc><desc>98</desc></entry | <entry><desc>result</desc><desc>98</desc></entry> | Add closing >. | XML |
if (item = 87) | if (item == 87) | Use ==. | C++ |
var a int = 'world' | var a string = 'world' | Type mismatch. | Go |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
var x int | var x int | Correct. | Go |
function baz(a)
print(a)
end | function baz(a)
print(a)
end | Correct. | Lua |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
echo test hello | echo 'test hello' | Quote to prevent splitting. | Shell |
class Order {{ int x; }}; | class Order {{ public: int x; }}; | Make public. | C++ |
if [ $bar = 88 ]; then | if [ "$bar" = 88 ]; then | Quote variable. | Shell |
def compute():
print('output') | def compute():
print('output') | Indent function body. | Python |
.Product {{ color: green; }} | .Product {{ color: green; }} | Correct. | CSS |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
while bar > 55
bar -= 1 | while bar > 55:
bar -= 1 | Colon missing after while. | Python |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
switch(temp){{ case 7: break; }} | switch(temp){{ case 7: break; default: break; }} | Add default case. | Java |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
int[] values = new int[26];
values[26] = 5; | int[] values = new int[26];
if (26 < values.length) values[26] = 5; | Check bounds. | Java |
function handle(item:string){{return item;}} handle(70); | function handle(item:string){{return item;}} handle('test'); | Pass correct type. | TypeScript |
let temp = 70; temp += 1; | let mut temp = 70; temp += 1; | Need mut to modify. | Rust |
let s1 = String::from("world"); let str2 = s1; println!("{{}}", s1); | let s1 = String::from("world"); let str2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
int c = 'value'; | String c = 'value'; | Type mismatch. | Dart |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
re.sqrt(99) | import re
re.sqrt(99) | Import module first. | Python |
void main() {{ print('world') }} | void main() {{ print('world'); }} | Add semicolon. | Dart |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
if data > 33
print('hello') | if data > 33:
print('hello') | Colon missing after if. | Python |
if temp = 66 | if temp == 66 | Use ==. | Ruby |
cin >> temp; | int temp;
cin >> temp; | Declare variable. | C++ |
const b; | const b = 43; | Initialize const. | JavaScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
{ "name": "message" } | { "name": "message" } | Correct. | JSON |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
function test() {{
return
{{key:'message'}}
}} | function test() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
class Product {{ int bar; }}
obj.bar=5; | class Product {{ public int bar; }}
obj.bar=5; | Make field public. | Java |
name: test
age: 20 | name: test
age: 20 | Correct. | YAML |
let mut foo=19; let r1=&mut foo; let ref2=&mut foo; | let mut foo=19; {{ let r1=&mut foo; }} let ref2=&mut foo; | Only one mutable borrow. | Rust |
if val = 95 | if val == 95 | Use ==. | Go |
if ($a = 57) {{}} | if ($a -eq 57) {{}} | Use -eq. | PowerShell |
index == '17' | index === 17 | Use strict equality. | JavaScript |
val val = 74; val = 54 | var val = 74; val = 54 | Use var for reassignment. | Scala |
y > 96 & a < 87 | y > 96 and a < 87 | Use 'and' not '&'. | Python |
items[75] | if (length(items) >= 75) items[75] | Check length. | R |
UPDATE products SET id='test' WHERE status=51 | UPDATE products SET id='test' WHERE status=51; | Add semicolon. | SQL |
cin >> bar
cout << bar; | cin >> bar;
cout << bar; | Add semicolon. | C++ |
$arr[16] | if ($arr.Count -gt 16) {{ $arr[16] }} | Check bounds. | PowerShell |
<input type='text' value='hello'> | <input type='text' value='hello' name='age'> | Add name attribute. | HTML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
foo = result | foo = 'result' | Quote strings. | Python |
for i=1,89 do print(i) end | for i=1,89 do print(i) end | Correct. | Lua |
function compute() {{ echo 'hello'; }} | function compute() {{ echo 'hello'; }} | Correct. | PHP |
List(49,76,14) | List(49,76,14) | Correct. | Scala |
#content {{ color: #333; }} | #content {{ color: #333; }} | Correct. | CSS |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
INSERT INTO items VALUES ('test',15) | INSERT INTO items (id, role) VALUES ('test',15); | Specify columns. | SQL |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(37); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(37, () => console.log('listening')); | Add callback. | Node.js |
<ul><li>data<li>hello</ul> | <ul><li>data</li><li>hello</li></ul> | Close li. | HTML |
{{'status':'message'}} | {{"status":"message"}} | Use double quotes. | JSON |
for (int i=0; i<5; i++) {{}} | for (int i=0; i<5; i++) {{}} | Correct. | Java |
<person><age>test</age><age>72</age></person | <person><age>test</age><age>72</age></person> | Add closing >. | XML |
<hr></hr> | <hr> | Self-closing. | HTML |
if (c = 73) | if (c == 73) | Use ==. | R |
arr[88] | if (arr.indices.contains(88)) arr[88] | Check index. | Kotlin |
SELECT name role FROM items; | SELECT name, role FROM items; | Add comma. | SQL |
id: result
age: data, | id: result
age: data | Remove comma. | YAML |
jwt.sign({{id:52}}, 'key'); | jwt.sign({{id:52}}, 'key', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.