Created
May 13, 2023 13:07
-
-
Save IgorZyktin/47a7f6ea3ad6de1f3853b2a8ce082988 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| odd = [ | |
| 0, | |
| 1, | |
| 3, | |
| 5, | |
| 7, | |
| 9, | |
| ] | |
| even = [ | |
| 0, | |
| 2, | |
| 4, | |
| 6, | |
| 8, | |
| ] | |
| total = [] | |
| def make_variants(_odd): | |
| if _odd: | |
| for n1 in odd: | |
| for n2 in even: | |
| for n3 in odd: | |
| for n4 in even: | |
| for n5 in odd: | |
| for n6 in even: | |
| for n7 in odd: | |
| total.append( | |
| ''.join( | |
| map( | |
| str, | |
| [ | |
| n1, | |
| n2, | |
| n3, | |
| n4, | |
| n5, | |
| n6, | |
| n7, | |
| ] | |
| ) | |
| ) | |
| ) | |
| else: | |
| for n1 in even: | |
| for n2 in odd: | |
| for n3 in even: | |
| for n4 in odd: | |
| for n5 in even: | |
| for n6 in odd: | |
| for n7 in even: | |
| total.append( | |
| ''.join( | |
| map( | |
| str, | |
| [ | |
| n1, | |
| n2, | |
| n3, | |
| n4, | |
| n5, | |
| n6, | |
| n7, | |
| ] | |
| ) | |
| ) | |
| ) | |
| def filter_5(): | |
| res = [] | |
| for each in total: | |
| good = each[-1] in ('0', '5') | |
| if good: | |
| res.append(good) | |
| return res | |
| def main(): | |
| global total | |
| make_variants(True) | |
| make_variants(False) | |
| total = list(set(total)) | |
| res = filter_5() | |
| print(f'{len(res)=}') | |
| if __name__ == '__main__': | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment