Created
February 11, 2024 01:07
-
-
Save Spebby/f59b1b7e5138646462406ea3486fd908 to your computer and use it in GitHub Desktop.
shifts a given number by a pseudo-random value to make it feel less arbitrary.
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
import random | |
import argparse | |
import sys | |
def naturaliseShift(num): | |
magnitude = int(num / 15) | |
shift = random.randint(-magnitude, magnitude) | |
return num + shift | |
def bulk_mode(): | |
nums = [] | |
for line in sys.stdin: | |
nums.append(int(line)) | |
if sys.stdout.isatty(): | |
print() | |
for n in nums: | |
print(naturaliseShift(n)) | |
if __name__ == "__main__": | |
parser = argparse.ArgumentParser(description="Naturalise Numbers") | |
parser.add_argument("-b", "--bulk", "-bulk", action="store_true", help="Bulk mode") | |
args = parser.parse_args() | |
if args.bulk: | |
bulk_mode() | |
else: | |
input = int(input("Enter a number: ")) | |
print(naturaliseShift(input)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment