aboutsummaryrefslogtreecommitdiff
path: root/challenge-108/abigail/python/ch-2.py
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2021-04-19 03:12:28 +0100
committerGitHub <noreply@github.com>2021-04-19 03:12:28 +0100
commita95e8f06e3854dfa1401c2e1619434c38d5255e5 (patch)
tree85dcc12a058e6f7d194c53ab698a3b3631feea6d /challenge-108/abigail/python/ch-2.py
parenta32b581203d9a24b302aa233ab52f0efb0e2de2d (diff)
parentcb14e653f808efab54343ccde87436a78e9e5f3b (diff)
downloadperlweeklychallenge-club-a95e8f06e3854dfa1401c2e1619434c38d5255e5.tar.gz
perlweeklychallenge-club-a95e8f06e3854dfa1401c2e1619434c38d5255e5.tar.bz2
perlweeklychallenge-club-a95e8f06e3854dfa1401c2e1619434c38d5255e5.zip
Merge pull request #3913 from Abigail/abigail/week-108
Abigail/week 108
Diffstat (limited to 'challenge-108/abigail/python/ch-2.py')
-rw-r--r--challenge-108/abigail/python/ch-2.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/challenge-108/abigail/python/ch-2.py b/challenge-108/abigail/python/ch-2.py
new file mode 100644
index 0000000000..161dcd862b
--- /dev/null
+++ b/challenge-108/abigail/python/ch-2.py
@@ -0,0 +1,38 @@
+#!/opt/local/bin/python
+
+#
+# See ../README.md
+#
+
+#
+# Run as: python ch-2.py
+#
+
+import sys
+
+COUNT = 10
+PLAIN = 0
+COMPUTE = 1
+
+type = PLAIN
+
+if len (sys . argv) > 1 and sys . argv [1] == "compute":
+ type = COMPUTE
+
+
+if type == PLAIN:
+ print ("1, 1, 2, 5, 15, 52, 203, 877, 4140, 21147")
+
+
+if type == COMPUTE:
+ bell = [[1]]
+ for x in range (1, COUNT - 1):
+ bell . append ([bell [x - 1] [x - 1]])
+ for y in range (1, x + 1):
+ bell [x] . append (bell [x] [y - 1] + bell [x - 1] [y - 1])
+
+ print (1, end = '')
+ for x in range (0, COUNT - 1):
+ print (",", bell [x] [x], end = '')
+
+ print ("")