Skip to main content

A Python Package for Competitive Programming

Project description

Fast Cp

A Python Library that contains various functions to make Competitive Programming easy. This Package includes pre-defined functions that are quite useful in Competitive Programming.

Purpose of Package

  • The main purpose of this package is to provide various functions that are helpful for Competitive Programming.

Features

  • Collections of fastcp
    • Collections of arrays
      • Unique
      • Subarr
      • Subseq
      • Freq
      • Length
    • Collections of strings
      • VowelCount
      • Freq
      • Substr
      • Subseq
    • Collections of bitMan
      • Binary
      • Hexa
      • Octal
      • Toggle
      • CountSetBits
      • BinToDecimal
      • OctToDecimal
      • HexToDecimal
    • Collections of math
      • Product
      • Sieve
      • IsPrime
      • Along with all functions in python 3.11.0 math library
    • Collections of search
      • Find
      • LowerBound
      • UpperBound
    • Collections of sorting
      • Sort
      • SortDict
      • SortDictValues
    • Collections of collections
      • MultMap
      • Along with all functions in python 3.11.0 collections library
    • Collections of dataStructures
      • minHeap
      • maxHeap
      • PriorityQueue
      • SimpleQueue
      • queue
      • Stack
      • Along with all functions in python 3.11.0 Queues library
    • Collections of trees
      • Create
      • Inorder
      • Preorder
      • Postorder
      • Levelorder
      • Search
      • NodeSum

Getting Started

This package can be found on PyPi. Hence you can install it using pip

Installation

pip install fastcp

Usage

importing all sub-packages from fastcp

>>> from fastcp import *
>>> subsequences = Subseq([1,2,3,4,5])

importing a single sub-package from fastcp

>>> from fastcp import bitMan
>>> toggled_number = bitMan.Toggle(123)

Examples

>>> from fastcp import arrays

>>> arrays.Freq([1,1,2,2,2,3])
{1:2, 2:3, 3:1}
>>> from fastcp import *

>>> Substr("python")
['python', 'ython', 'thon', 'hon', 'on', 'n']

>>> Subseq("Pypi")
['Pypi', 'Pyp', 'Pyi', 'Py', 'Ppi', 'Pp', 'Pi', 'P', 'ypi', 'yp', 'yi', 'y', 'pi', 'p', 'i', '']
  • New Libraries: (v.1.0.2)
    • sorting
    • collections
>>> from fastcp import sorting
>>> # Sort function at O(N) Complexity

>>> dict = {10: 1, 8: 2, 1: 3, 4: 4}

>>> print(sorting.SortDict(dict))
{1: 3, 4: 4, 8: 2, 10: 1}

>>> print(sorting.SortDict(dict, True))
{10: 1, 8: 2, 4: 4, 1: 3}


>>> from fastcp import *

>>> d = MultMap(0)
>>> # creates a Multi-Dictionary with default value as Int (0);
>>> d[0][0]
0

>>> d = MultMap([])
>>> # creates a Multi-Dictionary with default value as List ([]);
>>> d[0][0]
[]
>>> d[0][0].append(20)
>>> d[0][0]
[20]
>>> d = defaultdict(int)
>>> d[0]
0
>>> from fastcp import dataStructures as ds 
>>> d = ds.maxHeap()
>>> # creates a maxHeap object (d)
>>> d.put(20)
>>> d.put(50)
>>> d.get()
50 # returns the max value in heap
>>> d.size()
1  # since 50 is removed from heap

>>> s = ds.Stack()
# create a stack data structure
>>> s.push(10)
>>> s.push(20)
>>> s.size()
2
>>> s.pop()
20
>>> s.pop()
10
>>> s.pop()
None

>>> d = ds.minHeap()
>>> # creates a minHeap object (d)
>>> d.put(20)
>>> d.put(50)
>>> d.get()
20 # returns the min value in heap
>>> d.size()
1  # since 20 is removed from heap
>>> from fastcp import trees
>>> root = trees.Create(10)
>>> root.left = Create(5)
>>> root.right = Create(20)
>>> trees.Inorder(root)
[5, 10, 20]
>>> trees.Preorder(root)
[10, 5, 20]
>>> trees.Postorder(root)
[5, 20, 10]
>>> trees.Levelorder(root)
[[10], [5, 20]]

Author

Avinash Doddi [https://github.com/avinash-doddi]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastcp-1.0.6.1.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

fastcp-1.0.6.1-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

Details for the file fastcp-1.0.6.1.tar.gz.

File metadata

  • Download URL: fastcp-1.0.6.1.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.0

File hashes

Hashes for fastcp-1.0.6.1.tar.gz
Algorithm Hash digest
SHA256 c17d344aff04a125d9cd4500e20a5c4a5e1406bc7aff2555c5edf231767c9b1b
MD5 f6d20dccf166c51a1d6b1c42623a2069
BLAKE2b-256 0170e05a5653c5a1c955d930ce2366b6cafa1ba57ffe0be81731de213a1f3e83

See more details on using hashes here.

File details

Details for the file fastcp-1.0.6.1-py3-none-any.whl.

File metadata

  • Download URL: fastcp-1.0.6.1-py3-none-any.whl
  • Upload date:
  • Size: 11.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.0

File hashes

Hashes for fastcp-1.0.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dfbcaf77fc3230561ab2d659f2393624863e3c457b572fe1a61d10f99e33f642
MD5 03ed588b8944119cc79fc518eab85d0a
BLAKE2b-256 a0b010de0184ad908f48e62710a0ef0de11a415219691d682be3544df5d9916e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page