diff options
Diffstat (limited to 'progs/a484.py')
-rw-r--r-- | progs/a484.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/progs/a484.py b/progs/a484.py new file mode 100644 index 0000000..00ed320 --- /dev/null +++ b/progs/a484.py @@ -0,0 +1,7 @@ +def check_triplet(A, n, sum, count):
+ if count == 3 and sum == 0:
+ return True
+ if count == 3 or n == 0 or sum < 0:
+ return False
+ return check_triplet(A, n - 1, sum - A[n - 1], count + 1) or\
+ check_triplet(A, n - 1, sum, count)
\ No newline at end of file |