1

Given a list of n timedelta objects, with the lowest denomination of time being minutes,

from datetime import timedelta as td

[td(days=1, hours=4, minutes=0),
 td(days=0, hours=2 minutes=30),
 td(days=3, hours=0 minutes=30),
 ...]

how can I find the lowest common multiple?

JakeCowton
  • 1,374
  • 5
  • 15
  • 35

1 Answers1

3

You could convert it all to seconds and get the LCM. Use timedelta.total_seconds()

https://docs.python.org/2/library/datetime.html

nitimalh
  • 919
  • 10
  • 26
  • 1
    Thanks. I used the second answer to https://stackoverflow.com/questions/147515/least-common-multiple-for-3-or-more-numbers to find the LCM of the total seconds in case anybody looks for that. – JakeCowton Feb 07 '15 at 04:51