Skip to content

Commit

Permalink
test: adding more tests to missing number algorithm (TheAlgorithms#10394
Browse files Browse the repository at this point in the history
)

* test: adding more tests to missing number algorithm

* Update missing_number.py

---------

Co-authored-by: Christian Clauss <[email protected]>
  • Loading branch information
2 people authored and sedatguzelsemme committed Sep 15, 2024
1 parent 7d5afdc commit f2514ed
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions bit_manipulation/missing_number.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ def find_missing_number(nums: list[int]) -> int:
Example:
>>> find_missing_number([0, 1, 3, 4])
2
>>> find_missing_number([4, 3, 1, 0])
2
>>> find_missing_number([-4, -3, -1, 0])
-2
>>> find_missing_number([-2, 2, 1, 3, 0])
-1
>>> find_missing_number([1, 3, 4, 5, 6])
2
>>> find_missing_number([6, 5, 4, 2, 1])
Expand All @@ -26,3 +32,9 @@ def find_missing_number(nums: list[int]) -> int:
missing_number ^= i ^ nums[i - low]

return missing_number


if __name__ == "__main__":
import doctest

doctest.testmod()

0 comments on commit f2514ed

Please sign in to comment.