aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <Mohammad.Anwar@yahoo.com>2025-10-22 00:50:00 +0100
committerGitHub <noreply@github.com>2025-10-22 00:50:00 +0100
commitc02f8e9b02916c13febfb27edd60aa8c1bda4ec2 (patch)
tree6c1d497f6fe551d1fdc76b9a5f053245c76ebe54
parent168cdea01e332bb9b9b40602504c8d2f153a173e (diff)
parent51475ae40e38d774ee38c503626c48a24bfa5c2c (diff)
downloadperlweeklychallenge-club-c02f8e9b02916c13febfb27edd60aa8c1bda4ec2.tar.gz
perlweeklychallenge-club-c02f8e9b02916c13febfb27edd60aa8c1bda4ec2.tar.bz2
perlweeklychallenge-club-c02f8e9b02916c13febfb27edd60aa8c1bda4ec2.zip
Merge pull request #12896 from packy/master
Tweaks to Elixir and Python solutions as extra files.
-rwxr-xr-xchallenge-344/packy-anderson/elixir/ch-1a.exs35
-rwxr-xr-xchallenge-344/packy-anderson/python/ch-1.py3
-rwxr-xr-xchallenge-344/packy-anderson/python/ch-1a.py23
3 files changed, 59 insertions, 2 deletions
diff --git a/challenge-344/packy-anderson/elixir/ch-1a.exs b/challenge-344/packy-anderson/elixir/ch-1a.exs
new file mode 100755
index 0000000000..eed0697e12
--- /dev/null
+++ b/challenge-344/packy-anderson/elixir/ch-1a.exs
@@ -0,0 +1,35 @@
+#!/usr/bin/env elixir
+
+defmodule PWC do
+ def compute(ints, x) do
+ ints
+ |> Enum.join
+ |> String.to_integer
+ |> Kernel.+(x)
+ |> Integer.to_string
+ |> String.graphemes
+ |> Enum.map(&String.to_integer/1)
+ end
+
+ def solution(ints, x) do
+ joined = Enum.join(ints, ", ")
+ IO.puts("Input: @ints = (#{joined}), $x = #{x}")
+ joined = Enum.join(compute(ints, x), ", ")
+ IO.puts("Output: (#{joined})")
+ end
+end
+
+IO.puts("Example 1:")
+PWC.solution([1, 2, 3, 4], 12)
+
+IO.puts("\nExample 2:")
+PWC.solution([2, 7, 4], 181)
+
+IO.puts("\nExample 3:")
+PWC.solution([9, 9, 9], 1)
+
+IO.puts("\nExample 4:")
+PWC.solution([1, 0, 0, 0, 0], 9999)
+
+IO.puts("\nExample 5:")
+PWC.solution([0], 1000)
diff --git a/challenge-344/packy-anderson/python/ch-1.py b/challenge-344/packy-anderson/python/ch-1.py
index 143d6cf8da..e39027da69 100755
--- a/challenge-344/packy-anderson/python/ch-1.py
+++ b/challenge-344/packy-anderson/python/ch-1.py
@@ -5,8 +5,7 @@ def compute(ints, x):
def solution(ints, x):
print(f'Input: @ints = ({"".join(map(str, ints))}), $x = {x}')
- print(f'Output: ({"".join(map(str, compute(ints, x)))})')
-
+ print(f'Output: ({", ".join(map(str, compute(ints, x)))})')
print('Example 1:')
solution([1, 2, 3, 4], 12)
diff --git a/challenge-344/packy-anderson/python/ch-1a.py b/challenge-344/packy-anderson/python/ch-1a.py
new file mode 100755
index 0000000000..2d6e9c52c4
--- /dev/null
+++ b/challenge-344/packy-anderson/python/ch-1a.py
@@ -0,0 +1,23 @@
+#!/usr/bin/env python
+
+def compute(ints, x):
+ return map(int, list(str(int("".join(map(str, ints))) + x)))
+
+def solution(ints, x):
+ print(f'Input: @ints = ({"".join(map(str, ints))}), $x = {x}')
+ print(f'Output: ({", ".join(map(str, compute(ints, x)))})')
+
+print('Example 1:')
+solution([1, 2, 3, 4], 12)
+
+print('\nExample 2:')
+solution([2, 7, 4], 181)
+
+print('\nExample 3:')
+solution([9, 9, 9], 1)
+
+print('\nExample 4:')
+solution([1, 0, 0, 0, 0], 9999)
+
+print('\nExample 5:')
+solution([0], 1000)