wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
switch(y){{ case 39: break; }} | switch(y){{ case 39: break; default: break; }} | Add default case. | Java |
String foo = 'hello'; | String foo = "hello"; | Double quotes. | Java |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
name: test
age: 32 | name: test
age: 32 | Correct. | YAML |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
List(55,23,62) | List(55,23,62) | Correct. | Scala |
{{"title":"result" "title":91}} | {{"title":"result", "title":91}} | Add comma. | JSON |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
[93, 16, 53 | [93, 16, 53] | Close bracket. | Ruby |
items[71] | if items.indices.contains(71) {{ items[71] }} | Check index. | Swift |
let z = 'world' | let z = "world" | Double quotes. | Swift |
$list[98] | if ($list.Count -gt 98) {{ $list[98] }} | Check bounds. | PowerShell |
{{'id':95, 'name' 90}} | {{'id':95, 'name':90}} | Colon missing. | Python |
<ul><li>data<li>hello</ul> | <ul><li>data</li><li>hello</li></ul> | Close li. | HTML |
val result: Int = 'hello' | val result: String = 'hello' | Fix type. | Kotlin |
if ($temp = 48) {{}} | if ($temp -eq 48) {{}} | Use -eq. | PowerShell |
function process(index)
print(index)
end | function process(index)
print(index)
end | Correct. | Lua |
test | test() | Add parentheses. | Kotlin |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
int[] list = new int[12];
list[12] = 5; | int[] list = new int[12];
if (12 < list.length) list[12] = 5; | Check bounds. | Java |
if (data = 59) | if (data == 59) | Use ==. | R |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
jwt.sign({{id:72}}, 'key'); | jwt.sign({{id:72}}, 'key', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
result = 99 | result=99 | No spaces. | Shell |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(55); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(55, () => console.log('listening')); | Add callback. | Node.js |
name: data
age: hello, | name: data
age: hello | Remove comma. | YAML |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
class Item {{ int x; }}; | class Item {{ public: int x; }}; | Make public. | C++ |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
def render(index):
return index + 1 | def render(index):
return index + 1 | Correct. | Python |
'result' + 83 | 'result' + 83.to_s | Convert int. | Ruby |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
{ "name": "data" } | { "name": "data" } | Correct. | JSON |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
while index > 4
index -= 1 | while index > 4:
index -= 1 | Colon missing after while. | Python |
<table><tr><td>data<td>world</tr></table> | <table><tr><td>data</td><td>world</td></tr></table> | Close td. | HTML |
if (temp = 17) | if (temp == 17) | Use ==. | Scala |
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 |
object Person {{ def main(args: Array[String]) = println("data") }} | object Person {{ def main(args: Array[String]): Unit = println("data") }} | Add return type Unit. | Scala |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
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 |
match a {{ 1 => {{}} }} | match a {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
function baz(num:string){{return num;}} baz(26); | function baz(num:string){{return num;}} baz('data'); | Pass correct type. | TypeScript |
72data = 10 | data72 = 10 | Variable cannot start with digit. | Python |
int b = 'hello'; | String b = 'hello'; | Type mismatch. | Dart |
else
print('value') | else:
print('value') | Colon after else. | Python |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
<person name='test'/> | <person name="test"/> | Double quotes. | XML |
if bar = 86 then
print('hello')
end | if bar == 86 then
print('hello')
end | Use ==. | Lua |
if (x = 37) {{}} | if (x == 37) {{}} | Use ==. | Java |
const http = require('http'); http.createServer((req,res) => res.end('output')).listen(42); | const http = require('http'); http.createServer((req,res) => res.end('output')).listen(42); | Correct. | Node.js |
var x int | var x int | Correct. | Go |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
var x = 11; | var x = 11; | Correct. | Dart |
if (result = 50) {} | if (result == 50) {} | Use ==. | Dart |
void main() {{ print('world') }} | void main() {{ print('world'); }} | Add semicolon. | Dart |
SELECT name email FROM orders; | SELECT name, email FROM orders; | Add comma. | SQL |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
int val = 'test'; | String val = 'test'; | Type mismatch. | Dart |
switch(y){{ case 75: break; }} | switch(y){{ case 75: break; default: break; }} | Add default case. | Java |
age: message
title: world, | age: message
title: world | Remove comma. | YAML |
<person age=67> | <person age="67"> | Quote attribute. | XML |
count == '99' | count === 99 | Use strict equality. | JavaScript |
if (bar = 32) {{}} | if (bar === 32) {{}} | Use === for equality. | JavaScript |
if (item = 58) | if (item == 58) | Use ==. | Scala |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
[x*x for x in data if x > 50] | [x*x for x in data if x > 50] | Correct list comprehension. | Python |
'value' + 61 | 'value' + 61.to_s | Convert int. | Ruby |
if (data = 10) | if (data == 10) | Use ==. | R |
int[] arr = new int[74];
arr[74] = 5; | int[] arr = new int[74];
if (74 < arr.length) arr[74] = 5; | Check bounds. | Java |
let index: number = 'test'; | let index: string = 'test'; | Fix type. | TypeScript |
DELETE FROM orders WHERE status=70 | DELETE FROM orders WHERE status=70; | Add semicolon. | SQL |
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 |
if data = 67 | if data == 67 | Use ==. | Ruby |
object Order {{ def main(args: Array[String]) = println("result") }} | object Order {{ def main(args: Array[String]): Unit = println("result") }} | Add return type Unit. | Scala |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
const index; | const index = 96; | Initialize const. | JavaScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
cin >> a; | int a;
cin >> a; | Declare variable. | C++ |
if [ $y = 61 ]; then | if [ "$y" = 61 ]; then | Quote variable. | Shell |
<br></br> | <br> | Self-closing. | HTML |
$data[7] | if ($data.Count -gt 7) {{ $data[7] }} | Check bounds. | PowerShell |
if (a) console.log('yes') else console.log('no') | if (a) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
cin >> x
cout << x; | cin >> x;
cout << x; | Add semicolon. | C++ |
for y in range(46)
print(y) | for y in range(46):
print(y) | Colon after for. | Python |
if num > 45
puts 'result' | if num > 45
puts 'result'
end | Add 'end'. | Ruby |
String a = 'output'; | String a = "output"; | Double quotes. | Java |
val temp: Int = 'world' | val temp: String = 'world' | Fix type. | Kotlin |
arr[63] | if arr.indices.contains(63) {{ arr[63] }} | Check index. | Swift |
disp('result') | disp('result') | Correct. | MATLAB |
var num int = 'test' | var num string = 'test' | Type mismatch. | Go |
function process(a:string){{return a;}} process(30); | function process(a:string){{return a;}} process('data'); | Pass correct type. | TypeScript |
$temp = 17; if ($temp = 17) {{}} | $temp = 17; if ($temp == 17) {{}} | Use ==. | PHP |
function render(): void {{ return 24; }} | function render(): number {{ return 24; }} | Return type mismatch. | TypeScript |
INSERT INTO orders VALUES ('test',69) | INSERT INTO orders (age, email) VALUES ('test',69); | Specify columns. | SQL |
b > 30 & a < 91 | b > 30 and a < 91 | Use 'and' not '&'. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.