mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-03 16:08:02 +00:00
Tweaked compress challenge to make it more explicit that you should only compress a string if it saves space. Fixes #2.
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Problem: Compress a string such that 'AAABCCDDDD' becomes 'A3B1C2D4'\n",
|
||||
"## Problem: Compress a string such that 'AAABCCDDDD' becomes 'A3B1C2D4'. Only compress the string if it saves space.\n",
|
||||
"\n",
|
||||
"* [Constraints](#Constraints)\n",
|
||||
"* [Test Cases](#Test-Cases)\n",
|
||||
@@ -40,9 +40,7 @@
|
||||
"* Can you use additional data structures? \n",
|
||||
" * Yes\n",
|
||||
"* Is this case sensitive?\n",
|
||||
" * Yes\n",
|
||||
"* Do you compress even if it doesn't save space?\n",
|
||||
" * No"
|
||||
" * Yes"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Problem: Compress a string such that 'AAABCCDDDD' becomes 'A3B1C2D4'\n",
|
||||
"## Problem: Compress a string such that 'AAABCCDDDD' becomes 'A3B1C2D4'. Only compress the string if it saves space.\n",
|
||||
"\n",
|
||||
"* [Constraints](#Constraints)\n",
|
||||
"* [Test Cases](#Test-Cases)\n",
|
||||
@@ -39,9 +39,7 @@
|
||||
"* Can you use additional data structures? \n",
|
||||
" * Yes\n",
|
||||
"* Is this case sensitive?\n",
|
||||
" * Yes\n",
|
||||
"* Do you compress even if it doesn't save space?\n",
|
||||
" * No"
|
||||
" * Yes"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -113,7 +111,7 @@
|
||||
" size += 2\n",
|
||||
" \n",
|
||||
" # If the compressed string size is greater than \n",
|
||||
" # or equal to string size, return string\n",
|
||||
" # or equal to string size, return original string\n",
|
||||
" if size >= len(string):\n",
|
||||
" return string\n",
|
||||
"\n",
|
||||
|
||||
Reference in New Issue
Block a user