diff options
| author | deadmarshal <adeadmarshal@gmail.com> | 2024-01-02 02:29:50 -0500 |
|---|---|---|
| committer | deadmarshal <adeadmarshal@gmail.com> | 2024-01-02 02:29:50 -0500 |
| commit | 754a0f9cce2dc07a97609f2b8bc642dfee61930f (patch) | |
| tree | 7bd79339617fc14720b3bc79d52453563b6e06e9 /challenge-250/deadmarshal/lua/ch-2.lua | |
| parent | 5f38c976cae9103ec02e413224d047d8b149956d (diff) | |
| download | perlweeklychallenge-club-754a0f9cce2dc07a97609f2b8bc642dfee61930f.tar.gz perlweeklychallenge-club-754a0f9cce2dc07a97609f2b8bc642dfee61930f.tar.bz2 perlweeklychallenge-club-754a0f9cce2dc07a97609f2b8bc642dfee61930f.zip | |
TWC250
Diffstat (limited to 'challenge-250/deadmarshal/lua/ch-2.lua')
| -rw-r--r-- | challenge-250/deadmarshal/lua/ch-2.lua | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/challenge-250/deadmarshal/lua/ch-2.lua b/challenge-250/deadmarshal/lua/ch-2.lua new file mode 100644 index 0000000000..a88eda2702 --- /dev/null +++ b/challenge-250/deadmarshal/lua/ch-2.lua @@ -0,0 +1,15 @@ +#!/usr/bin/env lua + +local function alphanumeric_string_value(t) + assert(type(t) == 'table','t must be a table!') + local max = 0 + for i=1,#t do + local n = t[i]:match('^%d+$') and tonumber(t[i]) or t[i]:len() + if n > max then max = n end + end + return max +end + +print(alphanumeric_string_value{'perl','2','000','python','r4ku'}) +print(alphanumeric_string_value{'001','1','000','0001'}) + |
