From 3805599dbadc060a476f6affe42104bd05b8b476 Mon Sep 17 00:00:00 2001 From: hello3ds Date: Fri, 19 Apr 2019 08:48:21 +0800 Subject: [PATCH 1/2] Add --- samples/function/recur.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/samples/function/recur.py b/samples/function/recur.py index e3f66076..952b6036 100755 --- a/samples/function/recur.py +++ b/samples/function/recur.py @@ -16,9 +16,10 @@ def fact(n): def move(n, a, b, c): if n == 1: print('move', a, '-->', c) - else: - move(n-1, a, c, b) - move(1, a, b, c) - move(n-1, b, a, c) + return + move(n-1, a, c, b) + print('move', a, '-->', c) + move(n-1, b, a, c) move(4, 'A', 'B', 'C') +move(3, 'A', 'B', 'C') From fd429b5a0dec9e1f99c54f43607242fa07272880 Mon Sep 17 00:00:00 2001 From: hello3ds Date: Fri, 19 Apr 2019 08:48:57 +0800 Subject: [PATCH 2/2] Revert "Add" This reverts commit 3805599dbadc060a476f6affe42104bd05b8b476. --- samples/function/recur.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/samples/function/recur.py b/samples/function/recur.py index 952b6036..e3f66076 100755 --- a/samples/function/recur.py +++ b/samples/function/recur.py @@ -16,10 +16,9 @@ def fact(n): def move(n, a, b, c): if n == 1: print('move', a, '-->', c) - return - move(n-1, a, c, b) - print('move', a, '-->', c) - move(n-1, b, a, c) + else: + move(n-1, a, c, b) + move(1, a, b, c) + move(n-1, b, a, c) move(4, 'A', 'B', 'C') -move(3, 'A', 'B', 'C')