Last active
May 29, 2017 02:01
-
-
Save mrjohannchang/051c78d38a127d0579928b884625aa1e to your computer and use it in GitHub Desktop.
This file contains 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
def solve(s: str, n: int, iseven: bool): | |
if n <= 0: | |
print(s) | |
return | |
i: int | |
for i in range(10) if iseven else range(9, -1, -1): | |
solve(s + chr(ord('0') + i), n - 1, i % 2 == 0 if iseven else i % 2 == 1) | |
solve('', int(input()), True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
迴圈的解法