aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <Mohammad.Anwar@yahoo.com>2025-07-31 11:17:00 +0100
committerGitHub <noreply@github.com>2025-07-31 11:17:00 +0100
commitee5da5b4bb1f3866d32f0725518ae6b9446f298e (patch)
tree5612ac8b864dbf8cbf32e030a7d2444f255efaf3
parent7fdc2162575a443cd7507360c34391d3fc59c755 (diff)
parent411310f9aaa52e5756ff901e6dd7e608c1b79b32 (diff)
downloadperlweeklychallenge-club-ee5da5b4bb1f3866d32f0725518ae6b9446f298e.tar.gz
perlweeklychallenge-club-ee5da5b4bb1f3866d32f0725518ae6b9446f298e.tar.bz2
perlweeklychallenge-club-ee5da5b4bb1f3866d32f0725518ae6b9446f298e.zip
Merge pull request #12434 from HVukman/branch-for-challenge-332
Branch for challenge 332
-rw-r--r--challenge-332/hvukman/f#/332_p1.fs11
-rw-r--r--challenge-332/hvukman/f#/332_p2.fs11
-rw-r--r--challenge-332/hvukman/k/332_p1.k5
-rw-r--r--challenge-332/hvukman/k/332_p2.k4
-rw-r--r--challenge-332/hvukman/lua/332_p1.lua39
-rw-r--r--challenge-332/hvukman/lua/332_p2.lua28
6 files changed, 98 insertions, 0 deletions
diff --git a/challenge-332/hvukman/f#/332_p1.fs b/challenge-332/hvukman/f#/332_p1.fs
new file mode 100644
index 0000000000..cc86707cf8
--- /dev/null
+++ b/challenge-332/hvukman/f#/332_p1.fs
@@ -0,0 +1,11 @@
+// 332 part 1
+
+let inp_list1 = [| "2025-07-26";"2000-02-02"; "2024-12-31"|];
+
+for i in inp_list1 do
+ let split = i.Split '-'
+ for j in 0 .. (Seq.length(split))-1 do
+ // conversion of int to Binary with "%B"
+ printf "%B" (System.Int32.Parse(split[j]))
+ if j <> (Seq.length(split))-1 then printf "%s" "-"
+ printf "\n"
diff --git a/challenge-332/hvukman/f#/332_p2.fs b/challenge-332/hvukman/f#/332_p2.fs
new file mode 100644
index 0000000000..81c9d24f39
--- /dev/null
+++ b/challenge-332/hvukman/f#/332_p2.fs
@@ -0,0 +1,11 @@
+// 332 part 2
+let inp_list = [| "weekly"; "perl"; "challenge"|];
+
+let odd x = Seq.toList x |>
+ // go over Seq and filter not equal characters
+ List.map (fun y -> String.filter (fun z -> y=z ) x) |>
+ // check if unique characters are in list in multiple of two
+ List.filter (fun w -> String.length(w)%2=0)
+
+for i in inp_list do
+ if List.length(odd i)>0 then printf "false\n" else printf "true\n"
diff --git a/challenge-332/hvukman/k/332_p1.k b/challenge-332/hvukman/k/332_p1.k
new file mode 100644
index 0000000000..76b325606b
--- /dev/null
+++ b/challenge-332/hvukman/k/332_p1.k
@@ -0,0 +1,5 @@
+/ add dash to element 0 and 1
+adddash: {(x[0],"-";x[1],"-";x[2])}
+/ convert int to binary string
+bin: {|,//${$[0=2!x;0;1]}'{x>1}{_x%2}\x}
+{,//adddash (bin'.'"-"\x)}'("2025-07-26";"2000-02-02";"2024-12-31")
diff --git a/challenge-332/hvukman/k/332_p2.k b/challenge-332/hvukman/k/332_p2.k
new file mode 100644
index 0000000000..f79f13aaed
--- /dev/null
+++ b/challenge-332/hvukman/k/332_p2.k
@@ -0,0 +1,4 @@
+/ check if element of vector is divisible by 2
+odd: {0=2!+/x=inp}
+/ looking for character x in word inp; inp is set as global variable
+{inp::x ; $[0=(+/{odd x}'x);"true";"false" ]}'("weekly";"perl";"challenge")
diff --git a/challenge-332/hvukman/lua/332_p1.lua b/challenge-332/hvukman/lua/332_p1.lua
new file mode 100644
index 0000000000..35b39a5b30
--- /dev/null
+++ b/challenge-332/hvukman/lua/332_p1.lua
@@ -0,0 +1,39 @@
+
+function Split(inputstr, sep)
+ if sep == nil then
+ sep = "%s"
+ end
+ local t = {}
+ for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
+ table.insert(t, str)
+ end
+ return t
+end
+
+function Bindate(inp)
+ local newdate = Split(inp,"-")
+ for k,v in ipairs(newdate) do
+
+ local n = tonumber(v)
+ local bin = {}
+ while n>0 do
+ table.insert(bin,n&1)
+ n = n >> 1
+ end
+
+ for i=#bin, 1, -1 do
+ io.write(bin[i])
+ end
+
+ if k~=#newdate then
+ io.write("-")
+ end
+
+
+ end
+ print("")
+end
+
+Bindate("2025-07-26")
+Bindate("2000-02-02")
+Bindate("2024-12-31")
diff --git a/challenge-332/hvukman/lua/332_p2.lua b/challenge-332/hvukman/lua/332_p2.lua
new file mode 100644
index 0000000000..1109670252
--- /dev/null
+++ b/challenge-332/hvukman/lua/332_p2.lua
@@ -0,0 +1,28 @@
+
+
+function Oddletters(inp)
+ local odd = true
+ for c in inp:gmatch"." do
+ -- print(c)
+ local i = 0
+
+ for _ in string.gmatch(inp,c) do
+ i = i+1
+ end
+
+
+ if i%2==0 then
+ print("false")
+ odd =false
+ end
+ if i%2 == 0 then break end
+
+ end
+ if odd==true then
+ print("true")
+ end
+end
+
+Oddletters("weelky")
+Oddletters("perl")
+Oddletters("challenge")