Created
May 5, 2020 03:39
-
-
Save ringowang/319de243abaff7b6e33e250c206202e7 to your computer and use it in GitHub Desktop.
Eloquent JavaScript 3.9 递归里面的函数 Python实现
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 find_solution(target): | |
def find(current, history): | |
if current == target: | |
return history | |
elif current > target: | |
return None | |
else: | |
return find(current + 5, "({} + 5)".format(history)) or find(current * 3, "({} * 3)".format(history)) | |
return find(1, "1") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment