aboutsummaryrefslogtreecommitdiff
path: root/challenge-225/deadmarshal/lua/ch-1.lua
diff options
context:
space:
mode:
author冯昶 <fengchang@novel-supertv.com>2023-07-17 18:07:20 +0800
committer冯昶 <fengchang@novel-supertv.com>2023-07-17 18:07:20 +0800
commit1d3872b50d7fe670c5910388f163da55ded8fa77 (patch)
tree50e95b7831dd9e3155a074b2a41e5fdf905063df /challenge-225/deadmarshal/lua/ch-1.lua
parent868de39e9ccd2c5187f4a34e78f5348e86698844 (diff)
parentd4c19914d808b095e1f4832042c5db8c645d0aae (diff)
downloadperlweeklychallenge-club-1d3872b50d7fe670c5910388f163da55ded8fa77.tar.gz
perlweeklychallenge-club-1d3872b50d7fe670c5910388f163da55ded8fa77.tar.bz2
perlweeklychallenge-club-1d3872b50d7fe670c5910388f163da55ded8fa77.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'challenge-225/deadmarshal/lua/ch-1.lua')
-rw-r--r--challenge-225/deadmarshal/lua/ch-1.lua19
1 files changed, 19 insertions, 0 deletions
diff --git a/challenge-225/deadmarshal/lua/ch-1.lua b/challenge-225/deadmarshal/lua/ch-1.lua
new file mode 100644
index 0000000000..816c08fc29
--- /dev/null
+++ b/challenge-225/deadmarshal/lua/ch-1.lua
@@ -0,0 +1,19 @@
+#!/usr/bin/env lua
+
+local function max_words(t)
+ local count,max = 0,0
+ for i=1, #t do
+ for _ in t[i]:gmatch("%s+") do count = count + 1 end
+ if count > max then max = count end
+ count = 0
+ end
+ return max+1
+end
+
+print(max_words({"Perl and Raku belong to the same family.",
+ "I love Perl.",
+ "The Perl and Raku Conference."}))
+print(max_words({"The Weekly Challenge.",
+ "Python is the most popular guest language.",
+ "Team PWC has over 300 members."}))
+