aboutsummaryrefslogtreecommitdiff
path: root/challenge-201/lubos-kolouch/python
diff options
context:
space:
mode:
authorLubos Kolouch <lubos@kolouch.net>2023-02-14 11:00:50 +0100
committerLubos Kolouch <lubos@kolouch.net>2023-02-20 20:24:52 +0100
commite98fa50d9dd47dd02ce01b6db838fd05ec0e1a97 (patch)
tree8d97833a6704d006ecb44bfde75a7fbb4efcb5af /challenge-201/lubos-kolouch/python
parent071b4dcd7d01a3a7e9aebcb60d0103ee427a8707 (diff)
downloadperlweeklychallenge-club-e98fa50d9dd47dd02ce01b6db838fd05ec0e1a97.tar.gz
perlweeklychallenge-club-e98fa50d9dd47dd02ce01b6db838fd05ec0e1a97.tar.bz2
perlweeklychallenge-club-e98fa50d9dd47dd02ce01b6db838fd05ec0e1a97.zip
Challenge 201 Task1 LK Python
Diffstat (limited to 'challenge-201/lubos-kolouch/python')
-rw-r--r--challenge-201/lubos-kolouch/python/ch-1.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/challenge-201/lubos-kolouch/python/ch-1.py b/challenge-201/lubos-kolouch/python/ch-1.py
new file mode 100644
index 0000000000..dc7229e912
--- /dev/null
+++ b/challenge-201/lubos-kolouch/python/ch-1.py
@@ -0,0 +1,28 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import unittest
+
+
+def find_missing_numbers(arr):
+ n = len(arr)
+ s = set(arr)
+ missing_numbers = []
+ for i in range(n + 1):
+ if i not in s:
+ missing_numbers.append(i)
+ return missing_numbers
+
+
+# test cases
+class TestMissingNumbers(unittest.TestCase):
+
+ def test_example1(self):
+ self.assertEqual(find_missing_numbers([0, 1, 3]), [2])
+
+ def test_example2(self):
+ self.assertEqual(find_missing_numbers([0, 1]), [2])
+
+
+if __name__ == '__main__':
+ unittest.main()