diff options
author | Martin Možina <martin.mozina@fri.uni-lj.si> | 2016-10-25 11:44:09 +0200 |
---|---|---|
committer | Martin Možina <martin.mozina@fri.uni-lj.si> | 2016-10-25 11:44:09 +0200 |
commit | 0bfa95be7046b101a00f83f082260b5d0e007159 (patch) | |
tree | 3d40f550b1b4ac620ca16914cef62f7066d2ef12 /python/problems/recursion/find_sum | |
parent | f12796f00b36d143d8e2735cbec988cad3a3e9e3 (diff) |
Added new exercises with recursion.
Added description for functions.
Diffstat (limited to 'python/problems/recursion/find_sum')
-rw-r--r-- | python/problems/recursion/find_sum/find_sum.py | 19 |
1 files changed, 0 insertions, 19 deletions
diff --git a/python/problems/recursion/find_sum/find_sum.py b/python/problems/recursion/find_sum/find_sum.py deleted file mode 100644 index 85f472b..0000000 --- a/python/problems/recursion/find_sum/find_sum.py +++ /dev/null @@ -1,19 +0,0 @@ -def find_sum(xs, gs): - if gs < 0: - return False - if gs == 0: - return True - if not xs: - return False - return find_sum(xs[1:], gs-xs[0]) or find_sum(xs[1:], gs) - -print (find_sum([2,7,3,1,4], 10)) -print (find_sum([2,3,2,4], 10)) -print (find_sum([], 10)) -print (find_sum([1,2,3], 2)) -print (find_sum([1,2,3], 7)) -print (find_sum([2,7,3,1,4], 9)) -print (find_sum([2,7,3,2,4], 17)) - - - |