This notebook was prepared by Donne Martin. Source and license info is on GitHub.
* None -> TypeError * [] -> [] * [0] -> [] * [0, 1] -> [1, 0] * [0, 1, 2] -> [2, 0, 0] * [1, 2, 3, 4] -> [24, 12, 8, 6]
Refer to the Solution Notebook. If you are stuck and need a hint, the solution notebook's algorithm discussion might be a good place to start.
class Solution(object):
def mult_other_numbers(self, array):
# TODO: Implement me
pass
The following unit test is expected to fail until you solve the challenge.
# %load test_mult_other_numbers.py
import unittest
class TestMultOtherNumbers(unittest.TestCase):
def test_mult_other_numbers(self):
solution = Solution()
self.assertRaises(TypeError, solution.mult_other_numbers, None)
self.assertEqual(solution.mult_other_numbers([0]), [])
self.assertEqual(solution.mult_other_numbers([0, 1]), [1, 0])
self.assertEqual(solution.mult_other_numbers([0, 1, 2]), [2, 0, 0])
self.assertEqual(solution.mult_other_numbers([1, 2, 3, 4]), [24, 12, 8, 6])
print('Success: test_mult_other_numbers')
def main():
test = TestMultOtherNumbers()
test.test_mult_other_numbers()
if __name__ == '__main__':
main()
Review the Solution Notebook for a discussion on algorithms and code solutions.