aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-332/packy-anderson/README.md2
-rw-r--r--challenge-332/packy-anderson/blog.txt1
-rwxr-xr-xchallenge-332/packy-anderson/elixir/ch-1.exs26
-rwxr-xr-xchallenge-332/packy-anderson/elixir/ch-2.exs38
-rwxr-xr-xchallenge-332/packy-anderson/perl/ch-1.pl20
-rwxr-xr-xchallenge-332/packy-anderson/perl/ch-2.pl25
-rwxr-xr-xchallenge-332/packy-anderson/python/ch-1.py17
-rwxr-xr-xchallenge-332/packy-anderson/python/ch-2.py21
-rwxr-xr-xchallenge-332/packy-anderson/raku/ch-1.raku20
-rwxr-xr-xchallenge-332/packy-anderson/raku/ch-2.raku23
10 files changed, 192 insertions, 1 deletions
diff --git a/challenge-332/packy-anderson/README.md b/challenge-332/packy-anderson/README.md
index 3bc9462275..00b39f4b47 100644
--- a/challenge-332/packy-anderson/README.md
+++ b/challenge-332/packy-anderson/README.md
@@ -23,4 +23,4 @@
## Blog Post
-[Perl Weekly Challenge: You have the last word, Buddy...](https://packy.dardan.com/b/Yw)
+[Perl Weekly Challenge: Oddly Binary](https://packy.dardan.com/b/ZQ)
diff --git a/challenge-332/packy-anderson/blog.txt b/challenge-332/packy-anderson/blog.txt
new file mode 100644
index 0000000000..1621a5fd0a
--- /dev/null
+++ b/challenge-332/packy-anderson/blog.txt
@@ -0,0 +1 @@
+https://packy.dardan.com/b/ZQ \ No newline at end of file
diff --git a/challenge-332/packy-anderson/elixir/ch-1.exs b/challenge-332/packy-anderson/elixir/ch-1.exs
new file mode 100755
index 0000000000..6972bdf7b7
--- /dev/null
+++ b/challenge-332/packy-anderson/elixir/ch-1.exs
@@ -0,0 +1,26 @@
+#!/usr/bin/env elixir
+
+defmodule PWC do
+
+ def binary_date(date) do
+ date
+ |> String.split("-")
+ |> Enum.map(fn s -> String.to_integer(s) end)
+ |> Enum.map(fn i -> Integer.digits(i, 2) |> Enum.join end)
+ |> Enum.join("-")
+ end
+
+ def solution(date) do
+ IO.puts("Input: $date = \"#{date}\"")
+ IO.puts("Output: \"#{binary_date(date)}\"")
+ end
+end
+
+IO.puts("Example 1:")
+PWC.solution("2025-07-26")
+
+IO.puts("\nExample 2:")
+PWC.solution("2000-02-02")
+
+IO.puts("\nExample 3:")
+PWC.solution("2024-12-31")
diff --git a/challenge-332/packy-anderson/elixir/ch-2.exs b/challenge-332/packy-anderson/elixir/ch-2.exs
new file mode 100755
index 0000000000..82446f4953
--- /dev/null
+++ b/challenge-332/packy-anderson/elixir/ch-2.exs
@@ -0,0 +1,38 @@
+#!/usr/bin/env elixir
+
+defmodule PWC do
+ def make_bag(list) do
+ {_, bag} = Enum.map_reduce(list, %{}, fn i, bag ->
+ { i, Map.put(bag, i, Map.get(bag, i, 0) + 1) }
+ end)
+ bag
+ end
+
+ def all_odd([]), do: "true"
+
+ def all_odd([this | rest]) do
+ if rem(this,2) == 0 do
+ "false"
+ else
+ all_odd(rest)
+ end
+ end
+
+ def odd_letters(str) do
+ str |> String.graphemes |> make_bag |> Map.values |> all_odd
+ end
+
+ def solution(str) do
+ IO.puts("Input: $str = \"#{str}\"")
+ IO.puts("Output: \"#{odd_letters(str)}\"")
+ end
+end
+
+IO.puts("Example 1:")
+PWC.solution("weekly")
+
+IO.puts("\nExample 2:")
+PWC.solution("perl")
+
+IO.puts("\nExample 3:")
+PWC.solution("challenge")
diff --git a/challenge-332/packy-anderson/perl/ch-1.pl b/challenge-332/packy-anderson/perl/ch-1.pl
new file mode 100755
index 0000000000..9c3382634f
--- /dev/null
+++ b/challenge-332/packy-anderson/perl/ch-1.pl
@@ -0,0 +1,20 @@
+#!/usr/bin/env perl
+use v5.40;
+
+sub binaryDate($date) {
+ join "-", map { sprintf "%b", $_ } split /\-/, $date;
+}
+
+sub solution($date) {
+ say qq/Input: \$date = "$date"/;
+ say qq/Output: "@{[binaryDate($date)]}"/;
+}
+
+say "Example 1:";
+solution("2025-07-26");
+
+say "\nExample 2:";
+solution("2000-02-02");
+
+say "\nExample 3:";
+solution("2024-12-31");
diff --git a/challenge-332/packy-anderson/perl/ch-2.pl b/challenge-332/packy-anderson/perl/ch-2.pl
new file mode 100755
index 0000000000..01d97119c1
--- /dev/null
+++ b/challenge-332/packy-anderson/perl/ch-2.pl
@@ -0,0 +1,25 @@
+#!/usr/bin/env perl
+use v5.40;
+
+sub oddLetters($str) {
+ my %letters;
+ map { $letters{$_}++ } split //, $str;
+ foreach my $times (values %letters) {
+ return 'false' if $times % 2 == 0;
+ }
+ return 'true';
+}
+
+sub solution($str) {
+ say qq/Input: \$str = "$str"/;
+ say qq/Output: @{[oddLetters($str)]}/;
+}
+
+say "Example 1:";
+solution("weekly");
+
+say "\nExample 2:";
+solution("perl");
+
+say "\nExample 3:";
+solution("challenge");
diff --git a/challenge-332/packy-anderson/python/ch-1.py b/challenge-332/packy-anderson/python/ch-1.py
new file mode 100755
index 0000000000..262e52844d
--- /dev/null
+++ b/challenge-332/packy-anderson/python/ch-1.py
@@ -0,0 +1,17 @@
+#!/usr/bin/env python
+
+def binary_date(date):
+ return '-'.join([ bin(int(i))[2:] for i in date.split('-')])
+
+def solution(date):
+ print(f'Input: $date = "{date}"')
+ print(f'Output: "{binary_date(date)}"')
+
+print('Example 1:')
+solution("2025-07-26")
+
+print('\nExample 2:')
+solution("2000-02-02")
+
+print('\nExample 3:')
+solution("2024-12-31")
diff --git a/challenge-332/packy-anderson/python/ch-2.py b/challenge-332/packy-anderson/python/ch-2.py
new file mode 100755
index 0000000000..35ef8de93f
--- /dev/null
+++ b/challenge-332/packy-anderson/python/ch-2.py
@@ -0,0 +1,21 @@
+#!/usr/bin/env python
+
+from collections import Counter
+
+def odd_letters(str_val):
+ for k,v in Counter(list(str_val)).items():
+ if v % 2 == 0: return 'false'
+ return 'true'
+
+def solution(str_val):
+ print(f'Input: $str = "{str_val}"')
+ print(f'Output: {odd_letters(str_val)}')
+
+print('Example 1:')
+solution("weekly")
+
+print('\nExample 2:')
+solution("perl")
+
+print('\nExample 3:')
+solution("challenge")
diff --git a/challenge-332/packy-anderson/raku/ch-1.raku b/challenge-332/packy-anderson/raku/ch-1.raku
new file mode 100755
index 0000000000..9c4bd03288
--- /dev/null
+++ b/challenge-332/packy-anderson/raku/ch-1.raku
@@ -0,0 +1,20 @@
+#!/usr/bin/env raku
+use v6;
+
+sub binaryDate($date) {
+ $date.split(/\-/).map({ .Int.base(2) }).join("-");
+}
+
+sub solution($date) {
+ say qq/Input: \$date = "$date"/;
+ say qq/Output: "{binaryDate($date)}"/;
+}
+
+say "Example 1:";
+solution("2025-07-26");
+
+say "\nExample 2:";
+solution("2000-02-02");
+
+say "\nExample 3:";
+solution("2024-12-31");
diff --git a/challenge-332/packy-anderson/raku/ch-2.raku b/challenge-332/packy-anderson/raku/ch-2.raku
new file mode 100755
index 0000000000..0340f421c5
--- /dev/null
+++ b/challenge-332/packy-anderson/raku/ch-2.raku
@@ -0,0 +1,23 @@
+#!/usr/bin/env raku
+use v6;
+
+sub oddLetters($str) {
+ for $str.comb.Bag.values -> $times {
+ return 'false' if $times % 2 == 0;
+ }
+ return 'true';
+}
+
+sub solution($str) {
+ say qq/Input: \$str = "$str"/;
+ say qq/Output: {oddLetters($str)}/;
+}
+
+say "Example 1:";
+solution("weekly");
+
+say "\nExample 2:";
+solution("perl");
+
+say "\nExample 3:";
+solution("challenge");