fixed problems, new pull

This commit is contained in:
wdonahoe
2015-07-11 10:43:28 -04:00
parent f703014dec
commit b4476d3f77
10 changed files with 193 additions and 65 deletions

View File

@@ -34,7 +34,6 @@
"source": [
"## Constraints\n",
"\n",
"* Can you assume the string is ASCII?\n",
" * Yes\n",
" * Note: Unicode strings could require special handling depending on your language\n",
@@ -73,15 +72,22 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"def unique_chars(string):\n",
" # TODO: Implement me\n",
" pass"
" from collections import defaultdict\n",
" \n",
" char_table = defaultdict(int)\n",
" for c in string:\n",
" if char_table[c] > 0:\n",
" return False\n",
" else:\n",
" char_table[c] = 1\n",
" return True"
]
},
{
@@ -100,11 +106,19 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Success: test_unique_chars\n"
]
}
],
"source": [
"# %load test_unique_chars.py\n",
"from nose.tools import assert_equal\n",
@@ -159,7 +173,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.10"
"version": "2.7.6"
}
},
"nbformat": 4,