-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8177acf
commit 4ecc1e7
Showing
7 changed files
with
27 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
|
||
from . import hash_seed | ||
|
||
__all__ = ['hash_seed'] | ||
__all__ = ["hash_seed"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,26 @@ | ||
import hashlib | ||
|
||
|
||
def hash_to_seed(input_string): | ||
""" | ||
Hash a string into a small integer seed less than 500. | ||
Parameters: | ||
input_string (str): The string to hash. | ||
Returns: | ||
int: A seed value (0 <= seed < 500). | ||
""" | ||
# Ensure the input is a string | ||
input_string = str(input_string) | ||
|
||
# Create a SHA-256 hash of the string | ||
hash_object = hashlib.sha256(input_string.encode()) | ||
|
||
# Convert the hash to an integer | ||
large_number = int.from_bytes(hash_object.digest(), 'big') | ||
large_number = int.from_bytes(hash_object.digest(), "big") | ||
|
||
# Reduce the number to a value less than 500 | ||
small_seed = large_number % 500 | ||
return small_seed | ||
|
||
return small_seed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
""" | ||
Dummy conftest.py for pykubegrader. | ||
Dummy conftest.py for pykubegrader. | ||
If you don't know what this is for, just leave it empty. | ||
Read more about conftest.py under: | ||
- https://docs.pytest.org/en/stable/fixture.html | ||
- https://docs.pytest.org/en/stable/writing_plugins.html | ||
If you don't know what this is for, just leave it empty. | ||
Read more about conftest.py under: | ||
- https://docs.pytest.org/en/stable/fixture.html | ||
- https://docs.pytest.org/en/stable/writing_plugins.html | ||
""" | ||
|
||
import pytest | ||
import pytest # noqa: F401 |