mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-05 08:58:02 +00:00
Move string rotation to a class
This commit is contained in:
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user