diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2021-04-19 03:13:31 +0100 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2021-04-19 03:13:31 +0100 |
| commit | bdaf92cab1ad3b96420087f98567cf8db00558d9 (patch) | |
| tree | 346680303a84263547d636326c6aec9f0ab28d84 /challenge-108/abigail/lua/ch-2.lua | |
| parent | 77842729c9b621c3e3e1167152f7862e34414c4e (diff) | |
| parent | a95e8f06e3854dfa1401c2e1619434c38d5255e5 (diff) | |
| download | perlweeklychallenge-club-bdaf92cab1ad3b96420087f98567cf8db00558d9.tar.gz perlweeklychallenge-club-bdaf92cab1ad3b96420087f98567cf8db00558d9.tar.bz2 perlweeklychallenge-club-bdaf92cab1ad3b96420087f98567cf8db00558d9.zip | |
Merge branch 'master' of https://github.com/manwar/perlweeklychallenge-club
Diffstat (limited to 'challenge-108/abigail/lua/ch-2.lua')
| -rw-r--r-- | challenge-108/abigail/lua/ch-2.lua | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/challenge-108/abigail/lua/ch-2.lua b/challenge-108/abigail/lua/ch-2.lua new file mode 100644 index 0000000000..37f067c465 --- /dev/null +++ b/challenge-108/abigail/lua/ch-2.lua @@ -0,0 +1,41 @@ +#!/opt/local/bin/lua + +-- +-- See ../README.md +-- + +-- +-- Run as: lua ch-2.lua +-- + +local COUNT = 10 +local PLAIN = 0 +local COMPUTE = 1 + +local type = PLAIN +if #arg >= 1 and arg [1] == "compute" +then type = COMPUTE +end + +if type == PLAIN +then print ("1, 1, 2, 5, 15, 52, 203, 877, 4140, 21147") +end + +if type == COMPUTE +then local bell = {} + bell [0] = {} + bell [0] [0] = 1 + for x = 1, COUNT - 2 + do bell [x] = {} + bell [x] [0] = bell [x - 1] [x - 1] + for y = 1, x + do bell [x] [y] = bell [x] [y - 1] + bell [x - 1] [y - 1] + end + end + + io . write (1) + for x = 0, COUNT - 2 + do io . write (", " .. bell [x] [x]) + end + io . write ("\n") +end |
