random-algorithm


Namerandom-algorithm JSON
Version 1.1.0 PyPI version JSON
download
home_pagehttps://github.com/EDM115/random-algorithm
SummaryA random number generator based on shuffled English words, their ASCII values, and the current epoch time to create highly randomized outputs
upload_time2024-09-19 17:44:51
maintainerNone
docs_urlNone
authorEDM115
requires_pythonNone
licenseMIT License Copyright (c) 2024 EDM115 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords random number generator ascii english algorithm
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # random_algorithm
A very simple yet original random algo made while overthinking about randomness
![PyPI - Version](https://img.shields.io/pypi/v/random_algorithm) ![PyPI - Downloads](https://img.shields.io/pypi/dm/random_algorithm) ![Pepy Total Downlods](https://img.shields.io/pepy/dt/random_algorithm)

`random_algorithm` is a Python library that generates random numbers using a novel approach based on English words and the current epoch time. It utilizes ASCII values of shuffled words, reduces them to single digits, and combines these digits to generate a random number of a specified size. This implementation attempts to get as close as possible to true randomness by using time-based factors and word shuffling.

## Features

- Generates random numbers based on shuffled English words.
- ASCII values of each word are reduced to single digits.
- Supports dynamic generation of random numbers of any specified size.
- Includes special logic to generate lower numbers (like `0` or `1`), which can sometimes be difficult to produce with traditional randomization methods.
- Provides functions to extract seeds based on time and to reduce any number to a single digit.

## Usage

Install the package in your repo

```bash
pip install random_algorithm
```

**If you use a requirements file, add this line to it :**

```bash
random_algorithm==1.1.0
```

You can import and use the library in your Python code like this :

```python
from random_algorithm import gen_random
```

Example :  
> Generate a random number with a desired size of 5 digits

```python
random_number = gen_random(desired_size=5)
print(f"Generated random number : {random_number}")
```

You can also use the following internal functions :
- `ascii_reduce(word, index)` :
   - Takes a word (ex `"github"`) and an index (can be any positive number) as input.
   - Reduces the word to a single digit (returns an `int`).
- `reduce_to_single_digit(n)` :
   - Reduces any integer `n` to a single digit by summing its digits repeatedly until one digit remains.
   - For example, `reduce_to_single_digit(9875)` would return `2`.
- `get_time_seed()` :
   - Generates a seed based on the current time and ASCII reduction of character permutations.

### Handling errors

`gen_random()` will raise the following exceptions if invalid inputs are provided :
- **`TypeError`** : Raised when `desired_size` is not an integer.
- **`ValueError`** : Raised when `desired_size` is less than 1.

> [!WARNING]  
> The code works fine but isn't the most optimized ever.  
> Generating huge numbers will take a lot of time ! I you really need a big random number, call the function multiple times with low numbers (ex 1 or 2) and concatenate the results

## How it works

1. **Word shuffling** : The words from `wordlist.txt` are shuffled on each call to ensure randomness.
2. **Random index** : The current epoch time is used to generate a random index into the shuffled word list.
3. **ASCII reduction** : Each word's ASCII values are reduced to single digits and then summed to produce a random number.
4. **Low numbers handling** : A special condition ensures that numbers like `0` and `1` can be generated using the current epoch time modulo operations.
5. 5. **Time Seed**: `get_time_seed()` creates a seed value based on permutations of characters from the current time.

## Contributing

Feel free to open an [issue](https://github.com/EDM115/random-algorithm/issues) or a [pull request](https://github.com/EDM115/random-algorithm/pulls) if you want to contribute to this project

### How to build ?

```bash
py -m pip install --upgrade pip build twine setuptools wheel
py -m build
py -m twine check dist/*
# Optional : publish to test.pypi.org
py -m twine upload --repository testpypi dist/*
# Or to pypi.org
py -m twine upload dist/*
```

## License

This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.  
The wordlist comes from from https://github.com/dwyl/english-words.

## Authors

- **[EDM115](https://github.com/EDM115)** - *Initial work*

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/EDM115/random-algorithm",
    "name": "random-algorithm",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "random, number, generator, ascii, english, algorithm",
    "author": "EDM115",
    "author_email": "EDM115 <dev@edm115.eu.org>",
    "download_url": "https://files.pythonhosted.org/packages/2d/1f/4e6c5ef4c9c2d0e4cc8830f9f73796d9c1d70d9188b6ef75d3b9eccf9f19/random_algorithm-1.1.0.tar.gz",
    "platform": null,
    "description": "# random_algorithm\r\nA very simple yet original random algo made while overthinking about randomness\r\n![PyPI - Version](https://img.shields.io/pypi/v/random_algorithm) ![PyPI - Downloads](https://img.shields.io/pypi/dm/random_algorithm) ![Pepy Total Downlods](https://img.shields.io/pepy/dt/random_algorithm)\r\n\r\n`random_algorithm` is a Python library that generates random numbers using a novel approach based on English words and the current epoch time. It utilizes ASCII values of shuffled words, reduces them to single digits, and combines these digits to generate a random number of a specified size. This implementation attempts to get as close as possible to true randomness by using time-based factors and word shuffling.\r\n\r\n## Features\r\n\r\n- Generates random numbers based on shuffled English words.\r\n- ASCII values of each word are reduced to single digits.\r\n- Supports dynamic generation of random numbers of any specified size.\r\n- Includes special logic to generate lower numbers (like `0` or `1`), which can sometimes be difficult to produce with traditional randomization methods.\r\n- Provides functions to extract seeds based on time and to reduce any number to a single digit.\r\n\r\n## Usage\r\n\r\nInstall the package in your repo\r\n\r\n```bash\r\npip install random_algorithm\r\n```\r\n\r\n**If you use a requirements file, add this line to it :**\r\n\r\n```bash\r\nrandom_algorithm==1.1.0\r\n```\r\n\r\nYou can import and use the library in your Python code like this :\r\n\r\n```python\r\nfrom random_algorithm import gen_random\r\n```\r\n\r\nExample :  \r\n> Generate a random number with a desired size of 5 digits\r\n\r\n```python\r\nrandom_number = gen_random(desired_size=5)\r\nprint(f\"Generated random number : {random_number}\")\r\n```\r\n\r\nYou can also use the following internal functions :\r\n- `ascii_reduce(word, index)` :\r\n   - Takes a word (ex `\"github\"`) and an index (can be any positive number) as input.\r\n   - Reduces the word to a single digit (returns an `int`).\r\n- `reduce_to_single_digit(n)` :\r\n   - Reduces any integer `n` to a single digit by summing its digits repeatedly until one digit remains.\r\n   - For example, `reduce_to_single_digit(9875)` would return `2`.\r\n- `get_time_seed()` :\r\n   - Generates a seed based on the current time and ASCII reduction of character permutations.\r\n\r\n### Handling errors\r\n\r\n`gen_random()` will raise the following exceptions if invalid inputs are provided :\r\n- **`TypeError`** : Raised when `desired_size` is not an integer.\r\n- **`ValueError`** : Raised when `desired_size` is less than 1.\r\n\r\n> [!WARNING]  \r\n> The code works fine but isn't the most optimized ever.  \r\n> Generating huge numbers will take a lot of time ! I you really need a big random number, call the function multiple times with low numbers (ex 1 or 2) and concatenate the results\r\n\r\n## How it works\r\n\r\n1. **Word shuffling** : The words from `wordlist.txt` are shuffled on each call to ensure randomness.\r\n2. **Random index** : The current epoch time is used to generate a random index into the shuffled word list.\r\n3. **ASCII reduction** : Each word's ASCII values are reduced to single digits and then summed to produce a random number.\r\n4. **Low numbers handling** : A special condition ensures that numbers like `0` and `1` can be generated using the current epoch time modulo operations.\r\n5. 5. **Time Seed**: `get_time_seed()` creates a seed value based on permutations of characters from the current time.\r\n\r\n## Contributing\r\n\r\nFeel free to open an [issue](https://github.com/EDM115/random-algorithm/issues) or a [pull request](https://github.com/EDM115/random-algorithm/pulls) if you want to contribute to this project\r\n\r\n### How to build ?\r\n\r\n```bash\r\npy -m pip install --upgrade pip build twine setuptools wheel\r\npy -m build\r\npy -m twine check dist/*\r\n# Optional : publish to test.pypi.org\r\npy -m twine upload --repository testpypi dist/*\r\n# Or to pypi.org\r\npy -m twine upload dist/*\r\n```\r\n\r\n## License\r\n\r\nThis project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.  \r\nThe wordlist comes from from https://github.com/dwyl/english-words.\r\n\r\n## Authors\r\n\r\n- **[EDM115](https://github.com/EDM115)** - *Initial work*\r\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024 EDM115  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "A random number generator based on shuffled English words, their ASCII values, and the current epoch time to create highly randomized outputs",
    "version": "1.1.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/EDM115/random-algorithm/issues",
        "Funding": "https://github.com/EDM115#support-me-",
        "Homepage": "https://github.com/EDM115/random-algorithm"
    },
    "split_keywords": [
        "random",
        " number",
        " generator",
        " ascii",
        " english",
        " algorithm"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "997c6fd1c0326e1f709514e66f463c03f3cb2b6e6c800009b81e5e8bdb8f608f",
                "md5": "acb34027731a8d02c5a56d0d9db92aee",
                "sha256": "18c17ae395ae5ca0f075637676e08bc8d885ac9d24ba3783f1f8df1be90b9b46"
            },
            "downloads": -1,
            "filename": "random_algorithm-1.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "acb34027731a8d02c5a56d0d9db92aee",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 1107233,
            "upload_time": "2024-09-19T17:44:47",
            "upload_time_iso_8601": "2024-09-19T17:44:47.497807Z",
            "url": "https://files.pythonhosted.org/packages/99/7c/6fd1c0326e1f709514e66f463c03f3cb2b6e6c800009b81e5e8bdb8f608f/random_algorithm-1.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2d1f4e6c5ef4c9c2d0e4cc8830f9f73796d9c1d70d9188b6ef75d3b9eccf9f19",
                "md5": "11e5f915e44b206dc723f75d12f748ce",
                "sha256": "fe0de2db16d4b00c4d10e234bb014c7aaf5a9995743ce664d95634fc33a077c7"
            },
            "downloads": -1,
            "filename": "random_algorithm-1.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "11e5f915e44b206dc723f75d12f748ce",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 1110055,
            "upload_time": "2024-09-19T17:44:51",
            "upload_time_iso_8601": "2024-09-19T17:44:51.140083Z",
            "url": "https://files.pythonhosted.org/packages/2d/1f/4e6c5ef4c9c2d0e4cc8830f9f73796d9c1d70d9188b6ef75d3b9eccf9f19/random_algorithm-1.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-19 17:44:51",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "EDM115",
    "github_project": "random-algorithm",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "random-algorithm"
}
        
Elapsed time: 0.30310s