Move string rotation to a class

This commit is contained in:
Donne Martin
2016-08-13 06:40:52 -04:00
parent 1fde26fcf5
commit 14a2751862
3 changed files with 35 additions and 30 deletions

View File

@@ -82,15 +82,16 @@
},
"outputs": [],
"source": [
"def is_substring(s1, s2):\n",
" # TODO: Implement me\n",
" pass\n",
"class Rotation(object):\n",
"\n",
" def is_substring(self, s1, s2):\n",
" # TODO: Implement me\n",
" pass\n",
"\n",
"def is_rotation(s1, s2):\n",
" # TODO: Implement me\n",
" # Call is_substring only once\n",
" pass"
" def is_rotation(self, s1, s2):\n",
" # TODO: Implement me\n",
" # Call is_substring only once\n",
" pass"
]
},
{
@@ -124,11 +125,12 @@
"class TestRotation(object):\n",
"\n",
" def test_rotation(self):\n",
" assert_equal(is_rotation('o', 'oo'), False)\n",
" assert_equal(is_rotation(None, 'foo'), False)\n",
" assert_equal(is_rotation('', 'foo'), False)\n",
" assert_equal(is_rotation('', ''), True)\n",
" assert_equal(is_rotation('foobarbaz', 'barbazfoo'), True)\n",
" rotation = Rotation()\n",
" assert_equal(rotation.is_rotation('o', 'oo'), False)\n",
" assert_equal(rotation.is_rotation(None, 'foo'), False)\n",
" assert_equal(rotation.is_rotation('', 'foo'), False)\n",
" assert_equal(rotation.is_rotation('', ''), True)\n",
" assert_equal(rotation.is_rotation('foobarbaz', 'barbazfoo'), True)\n",
" print('Success: test_rotation')\n",
"\n",
"\n",