Mar-17-2023, 07:59 PM
Here is my last word
__version__ = '2023.03.17.2' def rounding(precision, value): y = 0.5 if value >= 0 else -0.5 return precision * int(y + value / precision) def interval(coord, scale): s = scale // 2 u = rounding(s, coord) return (u - s, u + s) if __name__ == '__main__': from random import randint for i in range(10): x = randint(0, 1000000) print(x, interval(x, 5000))
Output:589802 (587500, 592500)
886897 (885000, 890000)
775585 (772500, 777500)
17445 (15000, 20000)
794528 (792500, 797500)
57525 (55000, 60000)
466087 (462500, 467500)
501046 (497500, 502500)
906234 (902500, 907500)
744038 (742500, 747500)