aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYitzchak Scott-Thoennes <sthoenna@gmail.com>2025-05-19 18:00:02 -0400
committerYitzchak Scott-Thoennes <sthoenna@gmail.com>2025-05-19 18:00:02 -0400
commit68f9929d37899a229ef9a247770e4032899e6639 (patch)
treeda1f82f860351e3eb9d1c90e7233690b7a055b8f
parent799aaa577a09c9a4f2d0271c5497c6ed0a839095 (diff)
downloadperlweeklychallenge-club-68f9929d37899a229ef9a247770e4032899e6639.tar.gz
perlweeklychallenge-club-68f9929d37899a229ef9a247770e4032899e6639.tar.bz2
perlweeklychallenge-club-68f9929d37899a229ef9a247770e4032899e6639.zip
challenge 322 perlish python solutions by ysth
-rw-r--r--challenge-322/ysth/python/ch-1.py18
-rw-r--r--challenge-322/ysth/python/ch-2.py17
2 files changed, 35 insertions, 0 deletions
diff --git a/challenge-322/ysth/python/ch-1.py b/challenge-322/ysth/python/ch-1.py
new file mode 100644
index 0000000000..739058f480
--- /dev/null
+++ b/challenge-322/ysth/python/ch-1.py
@@ -0,0 +1,18 @@
+import itertools
+import sys
+
+string = sys.argv[1]
+group_size = int(sys.argv[2])
+
+print(
+ "-".join(
+ reversed(
+ [
+ "".join(reversed(group))
+ for group in itertools.batched(
+ reversed(string.replace("-", "")), group_size
+ )
+ ]
+ )
+ )
+)
diff --git a/challenge-322/ysth/python/ch-2.py b/challenge-322/ysth/python/ch-2.py
new file mode 100644
index 0000000000..75301f87a5
--- /dev/null
+++ b/challenge-322/ysth/python/ch-2.py
@@ -0,0 +1,17 @@
+import sys
+
+integers = [int(value) for value in sys.argv[1:]]
+
+print(
+ " ".join(
+ list(
+ map(
+ {
+ value: str(i + 1)
+ for i, value in enumerate(sorted(set(integers)))
+ }.__getitem__,
+ integers,
+ )
+ )
+ )
+)