wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let text = String::from("value"); let borrow=&text; text.push_str("!"); | let mut text = String::from("value"); let borrow=&text; println!("{{}}", borrow); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
if b = 96: | if b == 96: | Use == for comparison. | Python |
int list[38]; list[38]=5; | int list[38]; if(38<38){{}} else list[38]=5; | Bounds check. | C++ |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
String name = 'world'; | String name = 'world'; | Correct. | Dart |
void main() {{ print('hello') }} | void main() {{ print('hello'); }} | Add semicolon. | Dart |
class Order {{ int item; }}; | class Order {{ public: int item; }}; | Make public. | C++ |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
x > 87 & b < 54 | x > 87 and b < 54 | Use 'and' not '&'. | Python |
let c: Int = 'value' | let c: String = 'value' | Fix type. | Swift |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(50); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(50, () => console.log('listening')); | Add callback. | Node.js |
print 'info' | print 'info'; | Add semicolon. | Perl |
val count = 'world' | val count = "world" | Double quotes. | Kotlin |
y = 77 | y=77 | No spaces. | Shell |
arr[8] | if (length(arr) >= 8) arr[8] | Check length. | R |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
items[12] | if (items.indices.contains(12)) items[12] | Check index. | Kotlin |
yield bar | yield bar | Correct yield. | Python |
if [ $y = 72 ]; then | if [ "$y" = 72 ]; then | Quote variable. | Shell |
$items[74] = 5; | if (isset($items[74])) $items[74] = 5; | Check existence. | PHP |
var data int = 'test' | var data string = 'test' | Type mismatch. | Go |
switch(temp){{ case 59: break; }} | switch(temp){{ case 59: break; default: break; }} | Add default case. | Java |
const item; | const item = 99; | Initialize const. | JavaScript |
def test
puts 'test'
end | def test
puts 'test'
end | Correct. | Ruby |
let data = 62; data += 1; | let mut data = 62; data += 1; | Need mut to modify. | Rust |
if (val = 27) | if (val == 27) | Use ==. | R |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
DELETE FROM users WHERE name=18 | DELETE FROM users WHERE name=18; | Add semicolon. | SQL |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
x := 92 | x := 92 | Correct. | Go |
if (b = 88) | if (b == 88) | Use ==. | Scala |
'result' + 48 | 'result' + 48.to_s | Convert int. | Ruby |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
if (index = 81) {{}} | if (index == 81) {{}} | Use ==. | Kotlin |
if val = 60 | if val == 60 | Use ==. | Ruby |
print 'message' | print('message') | print needs parentheses. | Python |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
#main {{ color: blue; }} | #main {{ color: blue; }} | Correct. | CSS |
let foo = 66; | let foo = 66; | Correct. | JavaScript |
const http = require('http'); http.createServer((req,res) => res.end('world')).listen(70); | const http = require('http'); http.createServer((req,res) => res.end('world')).listen(70); | Correct. | Node.js |
fmt.Println 'hello' | fmt.Println('hello') | Missing parentheses. | Go |
list[30] | if (list.indices.contains(30)) list[30] | Check index. | Kotlin |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(87); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(87, () => console.log('listening')); | Add callback. | Node.js |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
item = 3 | item=3 | No spaces. | Shell |
jwt.sign({{id:73}}, 'key'); | jwt.sign({{id:73}}, 'key', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
int values[91]; values[91]=5; | int values[91]; if(91<91){{}} else values[91]=5; | Bounds check. | C++ |
{{'title':'test'}} | {{"title":"test"}} | Use double quotes. | JSON |
println('data') | println("data") | Double quotes. | Scala |
let s1 = String::from("result"); let str2 = s1; println!("{{}}", s1); | let s1 = String::from("result"); let str2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if bar = 38 | if bar == 38 | Use ==. | Ruby |
def render
puts 'message'
end | def render
puts 'message'
end | Correct. | Ruby |
<img src='hello.jpg'> | <img src='hello.jpg' alt='desc'> | Add alt text. | HTML |
x := 32 | x := 32 | Correct. | Go |
List(88,36,35) | List(88,36,35) | Correct. | Scala |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
// comment | /* comment */ | Use /* */. | CSS |
class Person {{ int x; }}; | class Person {{ public: int x; }}; | Make public. | C++ |
function compute(temp)
print(temp)
end | function compute(temp)
print(temp)
end | Correct. | Lua |
object User {{ def main(args: Array[String]) = println("test") }} | object User {{ def main(args: Array[String]): Unit = println("test") }} | Add return type Unit. | Scala |
fn bar() -> i32 {{ 53 }} | fn bar() -> i32 {{ 53 }} | Correct. | Rust |
let val: Int = 'world' | let val: String = 'world' | Fix type. | Swift |
<person age=98> | <person age="98"> | Quote attribute. | XML |
SELECT * FROM users WHRE age=27; | SELECT * FROM users WHERE age=27; | Fix WHERE. | SQL |
void main() {{ print('world') }} | void main() {{ print('world'); }} | Add semicolon. | Dart |
cin >> b
cout << b; | cin >> b;
cout << b; | Add semicolon. | C++ |
<user><name>world</name><age>85</age></user | <user><name>world</name><age>85</age></user> | Add closing >. | XML |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
JOIN orders ON products.id = orders.age | JOIN orders ON products.id = orders.age | Correct. | SQL |
if foo = 83 {{}} | if foo == 83 {{}} | Use ==. | Swift |
print('hello') | print('hello') | Correct. | R |
{ "name": "world" } | { "name": "world" } | Correct. | JSON |
val data = 29; data = 56 | var data = 29; data = 56 | Use var for reassignment. | Scala |
int[] list = new int[80];
list[80] = 5; | int[] list = new int[80];
if (80 < list.length) list[80] = 5; | Check bounds. | Java |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
disp('test') | disp('test') | Correct. | MATLAB |
for (y in items) | for (y of items) | for...in iterates keys. | JavaScript |
[x*x for x in list if x > 9] | [x*x for x in list if x > 9] | Correct list comprehension. | Python |
if (x = 100) | if (x == 100) | Use ==. | C++ |
if bar = 13 | if bar == 13 | Use ==. | Go |
function render() {{ echo 'world'; }} | function render() {{ echo 'world'; }} | Correct. | PHP |
'message' + 34 | 'message' + 34.to_s | Convert int. | Ruby |
INSERT INTO orders VALUES ('test',85) | INSERT INTO orders (age, role) VALUES ('test',85); | Specify columns. | SQL |
for num in range(87)
print(num) | for num in range(87):
print(num) | Colon after for. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
$arr[98] | if ($arr.Count -gt 98) {{ $arr[98] }} | Check bounds. | PowerShell |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
<table><tr><td>hello<td>test</tr></table> | <table><tr><td>hello</td><td>test</td></tr></table> | Close td. | HTML |
def bar(item):
return item + 1 | def bar(item):
return item + 1 | Correct. | Python |
[37, 75, 43 | [37, 75, 43] | Close bracket. | Ruby |
def foo():
print('world') | def foo():
print('world') | Indent function body. | Python |
if (z = 23) {{}} | if (z == 23) {{}} | Use ==. | Java |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.