Skip to main content
added 22 characters in body; deleted 6 characters in body; edited body; edited body
Source Link
Jonathan Allan
  • 110.1k
  • 7
  • 65
  • 282

Python 3.8 (pre-release), 9084 bytes

-6 bytes thanks to Gloweye

lambda s,e,n:[d for i in range((e-s).days+1)if-len(set(d:=str(s+s+type(e-s).__class__(i))))==~n]

An unnamed function which returns a list of strings (counting/including leading zeros) that accepts three arguments:

  • s, the start - a datetime.date object;
  • e, the end - a datetime.date object; and
  • n, the number of days - an int object.

Try it online!Try it online!

Note: As the function accepts datetime.date objects I have not counted the import code for that (and have worked around importing the datetime.timedelta object as it is indirectly accessible via subtraction of these input objects).

Python 3.8 (pre-release), 90 bytes

lambda s,e,n:[d for i in range((e-s).days+1)if-len(set(d:=str(s+(e-s).__class__(i))))==~n]

An unnamed function which returns a list of strings (counting/including leading zeros) that accepts three arguments:

  • s, the start - a datetime.date object;
  • e, the end - a datetime.date object; and
  • n, the number of days - an int object.

Try it online!

Note: As the function accepts datetime.date objects I have not counted the import code for that (and have worked around importing the datetime.timedelta object as it is indirectly accessible via subtraction of these input objects).

Python 3.8 (pre-release), 84 bytes

-6 bytes thanks to Gloweye

lambda s,e,n:[d for i in range((e-s).days+1)if-len(set(d:=str(s+type(e-s)(i))))==~n]

An unnamed function which returns a list of strings (counting/including leading zeros) that accepts three arguments:

  • s, the start - a datetime.date object;
  • e, the end - a datetime.date object; and
  • n, the number of days - an int object.

Try it online!

Note: As the function accepts datetime.date objects I have not counted the import code for that (and have worked around importing the datetime.timedelta object as it is indirectly accessible via subtraction of these input objects).

Source Link
Jonathan Allan
  • 110.1k
  • 7
  • 65
  • 282

Python 3.8 (pre-release), 90 bytes

lambda s,e,n:[d for i in range((e-s).days+1)if-len(set(d:=str(s+(e-s).__class__(i))))==~n]

An unnamed function which returns a list of strings (counting/including leading zeros) that accepts three arguments:

  • s, the start - a datetime.date object;
  • e, the end - a datetime.date object; and
  • n, the number of days - an int object.

Try it online!

Note: As the function accepts datetime.date objects I have not counted the import code for that (and have worked around importing the datetime.timedelta object as it is indirectly accessible via subtraction of these input objects).