Skip to content

Instantly share code, notes, and snippets.

@Spebby
Created February 11, 2024 01:07
Show Gist options
  • Save Spebby/f59b1b7e5138646462406ea3486fd908 to your computer and use it in GitHub Desktop.
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.
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