From fcd352576e64dd7156578f626b5e91f9dbd41438 Mon Sep 17 00:00:00 2001 From: deadmarshal Date: Fri, 14 Jul 2023 08:12:41 +0330 Subject: TWC225 --- challenge-225/deadmarshal/lua/ch-1.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 challenge-225/deadmarshal/lua/ch-1.lua (limited to 'challenge-225/deadmarshal/lua/ch-1.lua') 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."})) + -- cgit