mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-06 17:38:02 +00:00
@@ -82,9 +82,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"class Permutations(object):\n",
|
||||
@@ -111,28 +109,26 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# %load test_permutations.py\n",
|
||||
"from nose.tools import assert_equal\n",
|
||||
"import unittest\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"class TestPermutations(object):\n",
|
||||
"class TestPermutations(unittest.TestCase):\n",
|
||||
"\n",
|
||||
" def test_permutations(self):\n",
|
||||
" permutations = Permutations()\n",
|
||||
" assert_equal(permutations.find_permutations(None), None)\n",
|
||||
" assert_equal(permutations.find_permutations(''), '')\n",
|
||||
" self.assertEqual(permutations.find_permutations(None), None)\n",
|
||||
" self.assertEqual(permutations.find_permutations(''), '')\n",
|
||||
" string = 'AABC'\n",
|
||||
" expected = [\n",
|
||||
" 'AABC', 'AACB', 'ABAC', 'ABCA',\n",
|
||||
" 'ACAB', 'ACBA', 'BAAC', 'BACA',\n",
|
||||
" 'BCAA', 'CAAB', 'CABA', 'CBAA'\n",
|
||||
" ]\n",
|
||||
" assert_equal(permutations.find_permutations(string), expected)\n",
|
||||
" self.assertEqual(permutations.find_permutations(string), expected)\n",
|
||||
" print('Success: test_permutations')\n",
|
||||
"\n",
|
||||
"\n",
|
||||
@@ -171,9 +167,9 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.5.0"
|
||||
"version": "3.7.2"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0
|
||||
"nbformat_minor": 1
|
||||
}
|
||||
|
||||
@@ -94,9 +94,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from collections import OrderedDict\n",
|
||||
@@ -148,9 +146,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
@@ -162,22 +158,22 @@
|
||||
],
|
||||
"source": [
|
||||
"%%writefile test_permutations.py\n",
|
||||
"from nose.tools import assert_equal\n",
|
||||
"import unittest\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"class TestPermutations(object):\n",
|
||||
"class TestPermutations(unittest.TestCase):\n",
|
||||
"\n",
|
||||
" def test_permutations(self):\n",
|
||||
" permutations = Permutations()\n",
|
||||
" assert_equal(permutations.find_permutations(None), None)\n",
|
||||
" assert_equal(permutations.find_permutations(''), '')\n",
|
||||
" self.assertEqual(permutations.find_permutations(None), None)\n",
|
||||
" self.assertEqual(permutations.find_permutations(''), '')\n",
|
||||
" string = 'AABC'\n",
|
||||
" expected = [\n",
|
||||
" 'AABC', 'AACB', 'ABAC', 'ABCA',\n",
|
||||
" 'ACAB', 'ACBA', 'BAAC', 'BACA',\n",
|
||||
" 'BCAA', 'CAAB', 'CABA', 'CBAA'\n",
|
||||
" ]\n",
|
||||
" assert_equal(permutations.find_permutations(string), expected)\n",
|
||||
" self.assertEqual(permutations.find_permutations(string), expected)\n",
|
||||
" print('Success: test_permutations')\n",
|
||||
"\n",
|
||||
"\n",
|
||||
@@ -193,9 +189,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
@@ -226,9 +220,9 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.5.0"
|
||||
"version": "3.7.2"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0
|
||||
"nbformat_minor": 1
|
||||
}
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
from nose.tools import assert_equal
|
||||
import unittest
|
||||
|
||||
|
||||
class TestPermutations(object):
|
||||
class TestPermutations(unittest.TestCase):
|
||||
|
||||
def test_permutations(self):
|
||||
permutations = Permutations()
|
||||
assert_equal(permutations.find_permutations(None), None)
|
||||
assert_equal(permutations.find_permutations(''), '')
|
||||
self.assertEqual(permutations.find_permutations(None), None)
|
||||
self.assertEqual(permutations.find_permutations(''), '')
|
||||
string = 'AABC'
|
||||
expected = [
|
||||
'AABC', 'AACB', 'ABAC', 'ABCA',
|
||||
'ACAB', 'ACBA', 'BAAC', 'BACA',
|
||||
'BCAA', 'CAAB', 'CABA', 'CBAA'
|
||||
]
|
||||
assert_equal(permutations.find_permutations(string), expected)
|
||||
self.assertEqual(permutations.find_permutations(string), expected)
|
||||
print('Success: test_permutations')
|
||||
|
||||
|
||||
@@ -23,4 +23,4 @@ def main():
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user