diff options
| author | Abigail <abigail@abigail.be> | 2021-04-15 18:35:14 +0200 |
|---|---|---|
| committer | Abigail <abigail@abigail.be> | 2021-04-15 18:35:14 +0200 |
| commit | b1620c481366a458f47ca2eaac91715da0914f9d (patch) | |
| tree | b8e06aa0472ef6a212590ae2a2dde4abcc49aa3e /challenge-108/abigail/lua/ch-2.lua | |
| parent | a5983ebcde7e49f77690d28461dcdfeb575dc834 (diff) | |
| download | perlweeklychallenge-club-b1620c481366a458f47ca2eaac91715da0914f9d.tar.gz perlweeklychallenge-club-b1620c481366a458f47ca2eaac91715da0914f9d.tar.bz2 perlweeklychallenge-club-b1620c481366a458f47ca2eaac91715da0914f9d.zip | |
Lua solution for week 108, part 2
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 |
