kikikiabc
2020-10-10 23:37:13 +08:00
换个说法:这个月你 10 号入职,今天是 20 号。其中,本月的 9-11 号、13-14 号,19-30 号都是公休或假期,请问你哪些天在上班?
感觉就是个集合的减法问题
def area(a, b): return set(list(range(a, b+1)))
a = area(10, 20)
b = area(13, 14)
print('a', a)
print('b', b)
print('a-b', a-b)
print(area(10, 20) - area(13, 14) - area(9, 11) - area(19, 30) - area(3, 4))
依次,或者不依次,减就行了
a {10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}
b {13, 14}
a-b {10, 11, 12, 15, 16, 17, 18, 19, 20}
{12, 15, 16, 17, 18}