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:
Donne Martin
2015-07-07 17:15:18 -04:00
parent 6810a9e715
commit 44b73e3367
2 changed files with 5 additions and 9 deletions

View File

@@ -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"
]
},
{

View File

@@ -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",