improved prime numbers implementation (#1606)

* improved prime numbers implementation

* fixup! Format Python code with psf/black push

* fix type hint

* fixup! Format Python code with psf/black push

* fix doctests

* updating DIRECTORY.md

* added prime tests with negative numbers

* using for instead filter

* updating DIRECTORY.md

* Remove unused typing.List

* Remove tab indentation

* print("Sorted order is:", " ".join(a))
This commit is contained in:
Níkolas Vargas
2019-12-07 02:39:08 -03:00
committed by Christian Clauss
parent ccc1ff2ce8
commit 938dd0bbb5
5 changed files with 41 additions and 27 deletions

View File

@@ -30,7 +30,8 @@ class Heap(object):
"""Performs changes required for swapping two elements in the heap"""
# First update the indexes of the items in index map.
self.pos_map[self.arr[i][0]], self.pos_map[self.arr[j][0]] = (
self.pos_map[self.arr[j][0]], self.pos_map[self.arr[i][0]]
self.pos_map[self.arr[j][0]],
self.pos_map[self.arr[i][0]],
)
# Then swap the items in the list.
self.arr[i], self.arr[j] = self.arr[j], self.arr[i]