wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
function test(count)
print(count)
end | function test(count)
print(count)
end | Correct. | Lua |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
my @arr = (67,49,35); | my @arr = (67,49,35); | Correct. | Perl |
let s1 = String::from("test"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("test"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(76); | const http = require('http'); http.createServer((req,res) => res.end('test')).listen(76); | Correct. | Node.js |
'output' + 58 | 'output' + 58.to_s | Convert int. | Ruby |
echo data test | echo 'data test' | Quote to prevent splitting. | Shell |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
<person><desc>test</desc><age>53</age></person | <person><desc>test</desc><age>53</age></person> | Add closing >. | XML |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
def compute():
print('value') | def compute():
print('value') | Indent function body. | Python |
for temp in range(46)
print(temp) | for temp in range(46):
print(temp) | Colon after for. | Python |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
if a = 72 then
print('data')
end | if a == 72 then
print('data')
end | Use ==. | Lua |
local val = 19 | local val = 19 | Correct. | Lua |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
let str1 = String::from("data"); let str2 = str1; println!("{{}}", str1); | let str1 = String::from("data"); let str2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
<ul><li>test<li>test</ul> | <ul><li>test</li><li>test</li></ul> | Close li. | HTML |
class Item {{ int foo; }}
obj.foo=5; | class Item {{ public int foo; }}
obj.foo=5; | Make field public. | Java |
y > 83 & y < 30 | y > 83 and y < 30 | Use 'and' not '&'. | Python |
let result = 56; result += 1; | let mut result = 56; result += 1; | Need mut to modify. | Rust |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
foo | foo() | Add parentheses. | Swift |
{{'name':'test'}} | {{"name":"test"}} | Use double quotes. | JSON |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
const z; | const z = 95; | Initialize const. | JavaScript |
fn process() -> i32 {{ 75 }} | fn process() -> i32 {{ 75 }} | Correct. | Rust |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
<input type='text' value='data'> | <input type='text' value='data' name='value'> | Add name attribute. | HTML |
{{"age":"message" "status":37}} | {{"age":"message", "status":37}} | Add comma. | JSON |
name: result
age: 72 | name: result
age: 72 | Correct. | YAML |
if index = 89: | if index == 89: | Use == for comparison. | Python |
let str = String::from("value"); let r=&str; str.push_str("!"); | let mut str = String::from("value"); let r=&str; println!("{{}}", r); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
print('world') | print('world') | Correct. | R |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
let vec=vec![68,8,11]; let primary=&vec[0]; vec.push(100); | let mut vec=vec![68,8,11]; let primary=vec[0]; vec.push(100); | Copy instead of reference. | Rust |
int values[66]; values[66]=5; | int values[66]; if(66<66){{}} else values[66]=5; | Bounds check. | C++ |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
values[50] | if values.indices.contains(50) {{ values[50] }} | Check index. | Swift |
$list[15] = 5; | if (isset($list[15])) $list[15] = 5; | Check existence. | PHP |
for (y in values) | for (y of values) | for...in iterates keys. | JavaScript |
try {{ throw 'output'; }} catch(e) {{}} | try {{ throw new Error('output'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
def bar
puts 'hello'
end | def bar
puts 'hello'
end | Correct. | Ruby |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
<p>message <b>world</p></b> | <p>message <b>world</b></p> | Nest properly. | HTML |
if z > 64
puts 'world' | if z > 64
puts 'world'
end | Add 'end'. | Ruby |
JOIN products ON items.id = products.name | JOIN products ON items.id = products.name | Correct. | SQL |
if bar = 80 | if bar == 80 | Use ==. | Go |
cin >> temp; | int temp;
cin >> temp; | Declare variable. | C++ |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
if (z = 54) | if (z == 54) | Use ==. | R |
bar == '45' | bar === 45 | Use strict equality. | JavaScript |
object Item {{ def main(args: Array[String]) = println("output") }} | object Item {{ def main(args: Array[String]): Unit = println("output") }} | Add return type Unit. | Scala |
if ($z = 83) {{}} | if ($z -eq 83) {{}} | Use -eq. | PowerShell |
function render() {{
return
{{key:'value'}}
}} | function render() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
let mut temp=94; let ref1=&mut temp; let r2=&mut temp; | let mut temp=94; {{ let ref1=&mut temp; }} let r2=&mut temp; | Only one mutable borrow. | Rust |
{{"title":"hello",}} | {{"title":"hello"}} | Remove trailing comma. | JSON |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
if (num = 38) {{}} | if (num == 38) {{}} | Use ==. | Java |
const item = 75; item = 86; | let item = 75; item = 86; | Cannot reassign const. | JavaScript |
y = 32 | y=32 | No spaces. | Shell |
["message", 91] | ["message", 91] | Correct. | JSON |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
int[] values = new int[74];
values[74] = 5; | int[] values = new int[74];
if (74 < values.length) values[74] = 5; | Check bounds. | Java |
function baz(foo)
print(foo)
end | function baz(foo)
print(foo)
end | Correct. | Lua |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
class Person {{ int data; }}; | class Person {{ public: int data; }}; | Make public. | C++ |
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
let x = 4; let x = 26; | let x = 4; x = 26; | Duplicate declaration. | JavaScript |
h1 {{ font-size:37px color:blue; }} | h1 {{ font-size:37px; color:blue; }} | Add semicolon. | CSS |
'value' + 71 | 'value' + 71.to_s | Convert int. | Ruby |
[14, 1, 25 | [14, 1, 25] | Close bracket. | Python |
'7' + 28 | 7 + 28 | Avoid string coercion. | JavaScript |
println('output') | println("output") | Double quotes. | Scala |
$x = 51; if ($x = 51) {{}} | $x = 51; if ($x == 51) {{}} | Use ==. | PHP |
x := 61 | x := 61 | Correct. | Go |
WHERE name = '81' | WHERE name = 81 | Don't quote integer. | SQL |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
<person name='info'/> | <person name="info"/> | Double quotes. | XML |
disp('result') | disp('result') | Correct. | MATLAB |
.User {{ color: green; }} | .User {{ color: green; }} | Correct. | CSS |
echo info world | echo 'info world' | Quote to prevent splitting. | Shell |
if ($data = 57) | if ($data == 57) | Use ==. | Perl |
SELECT * FROM users WHRE status=8; | SELECT * FROM users WHERE status=8; | Fix WHERE. | SQL |
int y = 'test'; | String y = 'test'; | Type mismatch. | Dart |
cin >> y
cout << y; | cin >> y;
cout << y; | Add semicolon. | C++ |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
id: result
age: world, | id: result
age: world | Remove comma. | YAML |
let c = 77; | let c = 77; | Correct. | JavaScript |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.