For all your adding needs, up to numbers of 250.
Project description
plus
For all your adding needs, up to numbers of about 250 because otherwise the maximum recursion depth is exceeded.
Installing
The package can be installed using pip install pluspy
.
Example
To get the sum of two positive integers a
and b
, you would use plus(a, b)
:
>>> from plus import plus
>>> plus(2, 5)
7
Keep in mind the module is called plus
, not pluspy
.
FAQ
What is plus?
Plus was made to redefine the '+'operator in a recursive way, without using the '+'-operator itself.
Why?
This library was inspired by the enormous amount of isEven
and isOdd
-type memes, including one where '+' was defined by hardcoding every possible combination of the first 100-or-so numbers.
It was not made with the intention of being used (obv.), but rather to see how ridiculous I could make this.
The last 5 lines (while
-loop & bitshift
) by themselves are actually enough to add two numbers together (and it doesn't exceed the maximum recursion depth instantly), which was also done for this very reason. That part being in there adds to the overall idea.
Why is there a cache?
Well you see, when using numbers above 10 it started to get a bit slow. Calculating plus(50, 20)
had been running for half an hour, and wasn't showing any signs of stopping any time soon.
This meant I had to introduce dynamic programming
to speed it up a bit, and store results of calculations that had been made before.
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
File details
Details for the file pluspy-0.0.3.tar.gz
.
File metadata
- Download URL: pluspy-0.0.3.tar.gz
- Upload date:
- Size: 2.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0.post20201221 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55d97b7ce6b2e80bf9219217d5c0c898f690fd67e9f199d25b16f3e16e9f48c4 |
|
MD5 | ba8c6f5685aefea122960c93377af7f8 |
|
BLAKE2b-256 | 938cf65cdd5731fc12c9022073c75d30f3e21ce40396f581c1a0ae8d496990f3 |
File details
Details for the file pluspy-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: pluspy-0.0.3-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0.post20201221 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 46146e8440baf00e459a6c24c78217a7c2cf3bb9f5ae60afa984fef849cc7baa |
|
MD5 | 8d372327dbed76155bb2e44b75df4da3 |
|
BLAKE2b-256 | f82a8242086e51680c2943d9d754762768d25d82eefef6f8ee059e182666a023 |