-1

What I want to do is to make specific minute be added from now. For example.

Let's assume that it's 10:09 now. Then the minute is gonna be 9. And we assume that the interval is 5 minutes. Then the list has to be like this:

[9, 14, 19, 24, 29, 34, 39, 44, 49, 54, 59, 4, 9, ....]

Does anyone has solution?

Mureinik
  • 297,002
  • 52
  • 306
  • 350

3 Answers3

1

One way to think about it is that each element is the starting minute plus the index times the interval, and then take the remainder from dividing by 60 (an hour). Put it all together and you get:

start = 9
interval = 5
minutes = [(start + i * interval) % 60 for i in range(1000)]
Mureinik
  • 297,002
  • 52
  • 306
  • 350
0

This is what you are looking for?

import datetime

interval = 5
result_size = 10
current_minute = datetime.datetime.now().minute
result = [(current_minute + i * interval) % 60 for i in range(result_size)]
Hugo
  • 31
  • 2
0
def minutes_generator(start, delta=5):
  x = start
  while True:
    yield x
    x = (x + delta) % 60

g = minutes_generator(9, 5)
lst  = [next(g) for _ in range(20)]
print(lst)  # --> [9, 14, 19, 24, 29, 34, 39, 44, 49, 54, 59, 4, 9, 14, 19, 24, 29, 34, 39, 44]
Lior Cohen
  • 5,570
  • 2
  • 14
  • 30