mirror of
https://github.com/donnemartin/interactive-coding-challenges.git
synced 2024-03-22 13:11:13 +08:00
Rename list_of_chars to reverse_string.
This commit is contained in:
parent
27a0bf786e
commit
21add6f4f5
|
@ -78,7 +78,7 @@
|
|||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def list_of_chars(list_chars):\n",
|
||||
"def reverse_string(list_chars):\n",
|
||||
" # TODO: Implement me\n",
|
||||
" pass"
|
||||
]
|
||||
|
@ -114,16 +114,16 @@
|
|||
"class TestReverse(object):\n",
|
||||
"\n",
|
||||
" def test_reverse(self):\n",
|
||||
" assert_equal(list_of_chars(None), None)\n",
|
||||
" assert_equal(list_of_chars(['']), [''])\n",
|
||||
" assert_equal(list_of_chars(\n",
|
||||
" assert_equal(reverse_string(None), None)\n",
|
||||
" assert_equal(reverse_string(['']), [''])\n",
|
||||
" assert_equal(reverse_string(\n",
|
||||
" ['f', 'o', 'o', ' ', 'b', 'a', 'r']),\n",
|
||||
" ['r', 'a', 'b', ' ', 'o', 'o', 'f'])\n",
|
||||
" print('Success: test_reverse')\n",
|
||||
"\n",
|
||||
" def test_reverse_inplace(self):\n",
|
||||
" target_list = ['f', 'o', 'o', ' ', 'b', 'a', 'r']\n",
|
||||
" list_of_chars(target_list)\n",
|
||||
" reverse_string(target_list)\n",
|
||||
" assert_equal(target_list, ['r', 'a', 'b', ' ', 'o', 'o', 'f'])\n",
|
||||
" print('Success: test_reverse_inplace')\n",
|
||||
"\n",
|
||||
|
@ -150,21 +150,21 @@
|
|||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 2",
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python2"
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 2
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython2",
|
||||
"version": "2.7.10"
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.4.3"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
|
|
@ -94,7 +94,7 @@
|
|||
"from __future__ import division\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def list_of_chars(chars):\n",
|
||||
"def reverse_string(chars):\n",
|
||||
" if chars is None:\n",
|
||||
" return None\n",
|
||||
" size = len(chars)\n",
|
||||
|
@ -163,16 +163,16 @@
|
|||
"class TestReverse(object):\n",
|
||||
"\n",
|
||||
" def test_reverse(self):\n",
|
||||
" assert_equal(list_of_chars(None), None)\n",
|
||||
" assert_equal(list_of_chars(['']), [''])\n",
|
||||
" assert_equal(list_of_chars(\n",
|
||||
" assert_equal(reverse_string(None), None)\n",
|
||||
" assert_equal(reverse_string(['']), [''])\n",
|
||||
" assert_equal(reverse_string(\n",
|
||||
" ['f', 'o', 'o', ' ', 'b', 'a', 'r']),\n",
|
||||
" ['r', 'a', 'b', ' ', 'o', 'o', 'f'])\n",
|
||||
" print('Success: test_reverse')\n",
|
||||
"\n",
|
||||
" def test_reverse_inplace(self):\n",
|
||||
" target_list = ['f', 'o', 'o', ' ', 'b', 'a', 'r']\n",
|
||||
" list_of_chars(target_list)\n",
|
||||
" reverse_string(target_list)\n",
|
||||
" assert_equal(target_list, ['r', 'a', 'b', ' ', 'o', 'o', 'f'])\n",
|
||||
" print('Success: test_reverse_inplace')\n",
|
||||
"\n",
|
||||
|
|
|
@ -4,16 +4,16 @@ from nose.tools import assert_equal
|
|||
class TestReverse(object):
|
||||
|
||||
def test_reverse(self):
|
||||
assert_equal(list_of_chars(None), None)
|
||||
assert_equal(list_of_chars(['']), [''])
|
||||
assert_equal(list_of_chars(
|
||||
assert_equal(reverse_string(None), None)
|
||||
assert_equal(reverse_string(['']), [''])
|
||||
assert_equal(reverse_string(
|
||||
['f', 'o', 'o', ' ', 'b', 'a', 'r']),
|
||||
['r', 'a', 'b', ' ', 'o', 'o', 'f'])
|
||||
print('Success: test_reverse')
|
||||
|
||||
def test_reverse_inplace(self):
|
||||
target_list = ['f', 'o', 'o', ' ', 'b', 'a', 'r']
|
||||
list_of_chars(target_list)
|
||||
reverse_string(target_list)
|
||||
assert_equal(target_list, ['r', 'a', 'b', ' ', 'o', 'o', 'f'])
|
||||
print('Success: test_reverse_inplace')
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user