mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-08 18:38:03 +00:00
fixed problems, new pull
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user