algokit-py 0.1.0__py3-none-any.whl → 0.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
algokit_py/__init__.py CHANGED
@@ -3,6 +3,7 @@ algokit_py - A minimal Python algorithms library
3
3
  """
4
4
 
5
5
  from algokit_py.search import binary_search, linear_search
6
+ from algokit_py.sort import insertion_sort
6
7
 
7
8
  __version__ = "0.1.0"
8
- __all__ = ["binary_search", "linear_search"]
9
+ __all__ = ["binary_search", "linear_search","insertion_sort"]
@@ -16,10 +16,11 @@ At every step, the algorithm maintains a range that is guaranteed to contain the
16
16
  from typing import Sequence, TypeVar
17
17
 
18
18
  T = TypeVar('T')
19
- # here we use Sequence because binary seach does not support for unindexed iterables
19
+ # here we use Sequence because binary search does not support for not indexed iterables.
20
+ # Binary search requires a sorted sequence.
20
21
  def binary_search(sequence: Sequence[T], target: T)-> int:
21
22
  """
22
- This function will perform the binary search
23
+ This function will perform the binary search. Sequence must be a sorted sequence
23
24
 
24
25
  :param sequence: sorted and indexed sequence
25
26
  :param target: value that you want to find
@@ -0,0 +1 @@
1
+ from .insertion import insertion_sort
@@ -0,0 +1,26 @@
1
+ from typing import MutableSequence, TypeVar
2
+
3
+ T = TypeVar('T')
4
+ def insertion_sort(sequence: MutableSequence[T])-> None:
5
+ """
6
+ At the start of iteration i, the subarray sequence[0:i] is sorted.
7
+
8
+ :param sequence
9
+ :return None
10
+
11
+ Worst Case Time Complexity: O(n²)
12
+ Space Complexity: O(1)
13
+ """
14
+ length = len(sequence)
15
+ for i in range(1, length):
16
+ key = sequence[i]
17
+ j = i-1
18
+ while sequence[j] > key and j >= 0:
19
+ sequence[j+1]= sequence[j]
20
+ j -= 1
21
+ sequence[j + 1] = key
22
+
23
+
24
+
25
+
26
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: algokit-py
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Summary: A minimal Python algorithms library with clean implementations of search algorithms
5
5
  Author: Chanaka Prasanna
6
6
  License: MIT
@@ -12,14 +12,27 @@ Description-Content-Type: text/markdown
12
12
 
13
13
  # algokit-py
14
14
 
15
- A lightweight Python algorithms library with clean, well-documented implementations.
15
+ A lightweight Python algorithms library with clean, well-documented, and tested implementations.
16
+ Designed for learning, interviews, and real-world algorithm reasoning.
16
17
 
17
18
  ## Features
19
+
20
+ ### Search Algorithms
18
21
  - Linear Search
19
- - Binary Search
22
+ - Binary Search (iterative, invariant-based)
23
+
24
+ ### Sorting Algorithms
25
+ - Insertion Sort (in-place, stable)
20
26
 
21
27
  ## Usage
22
28
 
29
+ ### Install
30
+
31
+ ```python
32
+ pip install algokit-py
33
+ ```
34
+
35
+ ### Search
23
36
  ```python
24
37
  from algokit_py.search import linear_search, binary_search
25
38
 
@@ -27,26 +40,11 @@ print(linear_search([1, 2, 3], 2))
27
40
  print(binary_search([1, 2, 3], 2))
28
41
  ```
29
42
 
30
-
31
- We will improve this later.
32
-
33
- ---
34
-
35
- ## STEP 6: Local Install Test (Very Important)
36
-
37
- From **project root**:
38
-
39
- ```powershell
40
- pip install -e .
41
- ```
42
-
43
- Then test:
44
-
45
- ```powershell
46
- python -c "from algokit_py.search import binary_search; print(binary_search([1,2,3], 2))"
47
- ```
48
-
49
- You must see:
43
+ ### Sorting
50
44
  ```python
51
- 1
45
+ from algokit_py.sort import insertion_sort
46
+
47
+ data = [3, 1, 2]
48
+ insertion_sort(data)
49
+ print(data) # [1, 2, 3]
52
50
  ```
@@ -0,0 +1,10 @@
1
+ algokit_py/__init__.py,sha256=a0JaDxWSgNSg4l9Ezc3Q_ERjw4J72lQuYx7__B89Aio,254
2
+ algokit_py/search/__init__.py,sha256=0xreC43bjUH_VRqJTv48VbPadrY4GQgP7y3PMQ5RR04,118
3
+ algokit_py/search/binary.py,sha256=y9EXEK2wlFuMU6wQfddrESe4CkL2umfH7K0Vl33vW9g,1421
4
+ algokit_py/search/linear.py,sha256=07bjqKVarTmYiC0Uw-Pg_EuNRcsAD4zsn9lfuprTJAc,451
5
+ algokit_py/sort/__init__.py,sha256=9U5wHjwlxvPxOo08uud9xYQ_LrbSV2G1BZJWyoee1ck,37
6
+ algokit_py/sort/insertion.py,sha256=JocOHbztnwaLaTtyMUOnJ5o-BaUih60WX_ooTAVfZp4,574
7
+ algokit_py-0.2.0.dist-info/METADATA,sha256=sNuU_10eTJAJz6XTPjvlYzi11t8ISMu8eMwpjsa3sJE,1136
8
+ algokit_py-0.2.0.dist-info/WHEEL,sha256=qELbo2s1Yzl39ZmrAibXA2jjPLUYfnVhUNTlyF1rq0Y,92
9
+ algokit_py-0.2.0.dist-info/top_level.txt,sha256=OqfCkcr7SFcMZHBQVKnTOy6Plaoq8t0A8M4CN6Hca0w,11
10
+ algokit_py-0.2.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.9.0)
2
+ Generator: setuptools (80.10.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,8 +0,0 @@
1
- algokit_py/__init__.py,sha256=xhI99pue6hsmyVVOCd60YTglScw-RcWssAdGBUg3yNY,193
2
- algokit_py/search/__init__.py,sha256=0xreC43bjUH_VRqJTv48VbPadrY4GQgP7y3PMQ5RR04,118
3
- algokit_py/search/binary.py,sha256=3VZ0ZMtANDProjkGZkX1NUpZZPmwfZF5CevpeJ-Bd-Q,1336
4
- algokit_py/search/linear.py,sha256=07bjqKVarTmYiC0Uw-Pg_EuNRcsAD4zsn9lfuprTJAc,451
5
- algokit_py-0.1.0.dist-info/METADATA,sha256=E8L-a1xjSM5L-SJoVaQZ7U1kepUg2mB_jvxRDhkPjwo,1041
6
- algokit_py-0.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
7
- algokit_py-0.1.0.dist-info/top_level.txt,sha256=OqfCkcr7SFcMZHBQVKnTOy6Plaoq8t0A8M4CN6Hca0w,11
8
- algokit_py-0.1.0.dist-info/RECORD,,