diff options
| author | Mohammad Sajid Anwar <Mohammad.Anwar@yahoo.com> | 2025-07-20 18:51:49 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-20 18:51:49 +0100 |
| commit | 60595068c5582befea80040e029c9c70816699ee (patch) | |
| tree | 2ff4defb7c43d78808369fedacb77319e24188e7 /challenge-330 | |
| parent | 2a1f2b3059c8e00822879023803b807fc7a06a52 (diff) | |
| parent | 1492116ef153836e6fa155eef2080f8fa7fb9da5 (diff) | |
| download | perlweeklychallenge-club-60595068c5582befea80040e029c9c70816699ee.tar.gz perlweeklychallenge-club-60595068c5582befea80040e029c9c70816699ee.tar.bz2 perlweeklychallenge-club-60595068c5582befea80040e029c9c70816699ee.zip | |
Merge pull request #12374 from HVukman/branch-for-challenge-330
Branch for challenge 330
Diffstat (limited to 'challenge-330')
| -rw-r--r-- | challenge-330/hvukman/F#/330_p1.fs | 7 | ||||
| -rw-r--r-- | challenge-330/hvukman/F#/330_p2.fs | 13 | ||||
| -rw-r--r-- | challenge-330/hvukman/lua/330_p1.lua | 23 | ||||
| -rw-r--r-- | challenge-330/hvukman/lua/330_p2.lua | 25 |
4 files changed, 68 insertions, 0 deletions
diff --git a/challenge-330/hvukman/F#/330_p1.fs b/challenge-330/hvukman/F#/330_p1.fs new file mode 100644 index 0000000000..3963f7d97d --- /dev/null +++ b/challenge-330/hvukman/F#/330_p1.fs @@ -0,0 +1,7 @@ +let str = "cab12" +let pat = "[A-Za-z]\d" +[<TailCall>] +let rec rec_repl n = if Regex.Match(n,pat).Success=true then rec_repl (Regex.Replace(n,pat,"")) else printf "%s\n" n +rec_repl "cab12" +rec_repl "xy99" +rec_repl "pa1erl" diff --git a/challenge-330/hvukman/F#/330_p2.fs b/challenge-330/hvukman/F#/330_p2.fs new file mode 100644 index 0000000000..ef8abf5b81 --- /dev/null +++ b/challenge-330/hvukman/F#/330_p2.fs @@ -0,0 +1,13 @@ +// Part 2 +let words = "PERL IS gREAT".Split(" ") + +let print_right n = if Seq.length(n)>2 then printf "%c" (Char.ToUpper(Seq.head(n))) else printf "%c" (Char.ToLower(Seq.head(n))) + for p in (Seq.tail(n)) do printf "%c" (Char.ToLower(p)) + printf " " + + +for m in "PERL IS gREAT".Split(" ") do print_right m +printf "\n" +for m in "THE weekly challenge".Split(" ") do print_right m +printf "\n" +for m in "YoU ARE A stAR".Split(" ") do print_right m diff --git a/challenge-330/hvukman/lua/330_p1.lua b/challenge-330/hvukman/lua/330_p1.lua new file mode 100644 index 0000000000..52efc57e23 --- /dev/null +++ b/challenge-330/hvukman/lua/330_p1.lua @@ -0,0 +1,23 @@ +function Nice (a) + local not_good = false + local new + for i = 1, string.len(a) do + local char = string.sub(a, i, i) + if string.match(char, "%d") then + new= string.sub(a, 1, i-2) .. string.sub(a, i+1, string.len(a)) + not_good= true + break + end + + end + if not_good==true then + return Nice(new) + end + print(a) + return a +end + +Nice("cab12") +Nice("xy99") +Nice("pa1erl") + diff --git a/challenge-330/hvukman/lua/330_p2.lua b/challenge-330/hvukman/lua/330_p2.lua new file mode 100644 index 0000000000..e6e56fb801 --- /dev/null +++ b/challenge-330/hvukman/lua/330_p2.lua @@ -0,0 +1,25 @@ +function TitleCapital (a)
+ words = {}
+ for word in a:gmatch("%w+") do
+ table.insert(words, word)
+ end
+ for i,v in ipairs(words) do
+ if string.len(v)>2 then
+ local char = string.sub(v, 1, 1)
+ io.write(string.upper(char))
+ for i = 2, string.len(v) do
+ local sub_char = string.sub(v, i, i)
+ io.write(string.lower(sub_char))
+ end
+ else
+ for i = 1, string.len(v) do
+ local sub_char = string.sub(v, i, i)
+ io.write(string.lower(sub_char))
+ end
+ end
+ io.write(" ")
+ end
+
+end
+
+TitleCapital("PERL IS gREAT")
\ No newline at end of file |
