diff options
Diffstat (limited to 'challenge-115/stuart-little/lua/ch-2.lua')
| -rwxr-xr-x | challenge-115/stuart-little/lua/ch-2.lua | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/challenge-115/stuart-little/lua/ch-2.lua b/challenge-115/stuart-little/lua/ch-2.lua new file mode 100755 index 0000000000..8b73910913 --- /dev/null +++ b/challenge-115/stuart-little/lua/ch-2.lua @@ -0,0 +1,19 @@ +#!/usr/bin/env lua + +-- run <script> <space-separated digits> + +table.sort(arg) +s = table.concat(arg,"") +fst,odds,rest = s:match("(.)([13579]*)(.*)") + +if fst and ("02468"):find(fst) then + print(s:reverse()) + os.exit() +end + +if rest and rest:sub(1,1) ~= "" and ("02468"):find(rest:sub(1,1)) then + print(rest:sub(2):reverse() .. odds:reverse() .. fst .. rest:sub(1,1)) + os.exit() +end + +print("No even digits.") |
