47 lines
1.0 KiB
Python
47 lines
1.0 KiB
Python
#!/usr/bin/env python3
|
||
# coding: utf8
|
||
|
||
"""sets-of-love.py"""
|
||
|
||
|
||
def love_meet(bob, alice):
|
||
"""
|
||
Function documentation
|
||
|
||
:Tests:
|
||
>>> alice = ['Ⅱ', 'Ⅳ', 'ⅩⅠⅩ', 'ⅩⅤ', 'Ⅳ', 'Ⅱ']
|
||
>>> bob = ['Ⅳ', 'Ⅲ', 'Ⅱ', 'ⅩⅩ', 'Ⅱ', 'ⅩⅩ']
|
||
>>> love_meet(bob, alice)
|
||
{'Ⅱ', 'Ⅳ'}
|
||
"""
|
||
|
||
meet_districts = [district for district in alice if district in bob]
|
||
result = set()
|
||
for district in meet_districts:
|
||
result.add(district)
|
||
|
||
return result
|
||
|
||
|
||
def affair_meet(bob, alice, silvester):
|
||
"""
|
||
Function documentation
|
||
|
||
:Tests:
|
||
>>> alice = ['Ⅱ', 'Ⅳ', 'Ⅱ', 'ⅩⅠⅩ', 'ⅩⅤ', 'Ⅳ', 'Ⅲ']
|
||
>>> bob = ['Ⅳ', 'Ⅲ', 'Ⅱ', 'ⅩⅩ', 'Ⅱ', 'ⅩⅩ']
|
||
>>> silvester = ['ⅩVⅢ', 'ⅩⅠⅩ', 'Ⅲ', 'Ⅰ', 'Ⅲ', 'ⅩVⅢ']
|
||
>>> affair_meet(bob, alice, silvester)
|
||
{'ⅩⅠⅩ'}
|
||
"""
|
||
|
||
return {district for district in alice if district in silvester and district not in bob}
|
||
|
||
|
||
|
||
|
||
|
||
if __name__ == "__main__":
|
||
import doctest
|
||
doctest.testmod()
|