This library simplifies the code
Project description
DinarLib
What is this?
This library simplifies the code
Intersec
A method for finding intersections of an array
def intersec(a,b):
c = []
for element in a:
if element in b:
c.append(element)
return len(c)
Quick_sort
The most optimized array sorting
def partition(sort_nums, begin, end):
part = begin
for i in range(begin+1, end+1):
if int(sort_nums[i][4]) <= int(sort_nums[begin][4]):
part += 1
sort_nums[i], sort_nums[part] = sort_nums[part], sort_nums[i]
sort_nums[part], sort_nums[begin] = sort_nums[begin], sort_nums[part]
return part
def quick_sort(sort_nums, begin=0, end=None):
if end is None:
end = len(sort_nums) - 1
def quick(sort_nums, begin, end):
if begin >= end:
return
part = partition(sort_nums, begin, end)
quick(sort_nums, begin, part-1)
quick(sort_nums, part+1, end)
return quick(sort_nums, begin, end)
Random_sum
The maximum and the sum of the numbers are accepted as input Allows you to randomly collect numbers in an array that will equal the amount specified in the parameter
def random_sum(n, num_terms = None):
num_terms = (num_terms or random.randint(2, n)) - 1
a = random.sample(range(1, abs(n)), num_terms) + [0, abs(n)]
list.sort(a)
return [a[i+1] - a[i] for i in range(len(a) - 1)]
Developer
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dinarlib-0.0.2.tar.gz.
File metadata
- Download URL: dinarlib-0.0.2.tar.gz
- Upload date:
- Size: 2.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eae0cd7e89deab3c6bfb38b8d5a3655b33500c0c732c1a6558f2a9447628712d
|
|
| MD5 |
21e5fceef514f2832a2e54508a6617f2
|
|
| BLAKE2b-256 |
052aaefc43629c288eeb78b800f919e4c7df8980d1fd4fb70a06807d36e472b1
|
File details
Details for the file dinarlib-0.0.2-py3-none-any.whl.
File metadata
- Download URL: dinarlib-0.0.2-py3-none-any.whl
- Upload date:
- Size: 3.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10ada868db01368e6d25fe8b43d6514fd58347500376efa4919ecf5104c0a9b3
|
|
| MD5 |
b68447eea1c1106ae1f3e6abff034484
|
|
| BLAKE2b-256 |
84c15c2227d66be5c357733de792d3efdd43b549e49fd49e02869b5ca2848eab
|