aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-190/ealvar3z/blog.txt1
-rw-r--r--challenge-190/ealvar3z/python/ch-1.py16
-rw-r--r--challenge-190/ealvar3z/python/ch-2.py47
3 files changed, 64 insertions, 0 deletions
diff --git a/challenge-190/ealvar3z/blog.txt b/challenge-190/ealvar3z/blog.txt
new file mode 100644
index 0000000000..11812a5649
--- /dev/null
+++ b/challenge-190/ealvar3z/blog.txt
@@ -0,0 +1 @@
+https://alvar3z.com/posts/perl-weekly-challenge-190/
diff --git a/challenge-190/ealvar3z/python/ch-1.py b/challenge-190/ealvar3z/python/ch-1.py
new file mode 100644
index 0000000000..e489011232
--- /dev/null
+++ b/challenge-190/ealvar3z/python/ch-1.py
@@ -0,0 +1,16 @@
+#!/usr/bin/env python3
+
+
+if __name__ == "__main__":
+
+ tests = ['Perl', 'TPF', 'PyThon', 'raku']
+
+ for w in tests:
+ match w:
+ case w if not w.isupper() and not w.istitle() and not w.islower():
+ print(f'Input: {w}')
+ print('Output: 0')
+ case _:
+ print(f'Input: {w}')
+ print('Output: 1')
+
diff --git a/challenge-190/ealvar3z/python/ch-2.py b/challenge-190/ealvar3z/python/ch-2.py
new file mode 100644
index 0000000000..f19628a486
--- /dev/null
+++ b/challenge-190/ealvar3z/python/ch-2.py
@@ -0,0 +1,47 @@
+#!/usr/bin/env python3
+from __future__ import annotations
+from unittest import main, TestCase
+from typing import List
+
+
+def runner(start: str, i: int, arg: str, result: List[str]) -> None:
+ l = len(arg)
+ if i == l:
+ result.append(start)
+ return
+ nums = [int(arg[i])]
+
+ if i + 1 < l:
+ nums.append(int(arg[i] + arg[i+1]))
+
+ diff = 1
+ for n in nums:
+ if 1 <= n and n <= 26:
+ c = chr(ord('A') + n - 1)
+ runner(start + c, i + diff, arg, result)
+ diff += 1
+
+
+def decode(arg: str) -> List[str]:
+ result = []
+ runner("", 0, arg, result)
+ return result
+
+
+class TestDecodeList(TestCase):
+
+
+ def test_example_one(self):
+ self.assertEqual(decode("11"), ["AA", "K"], 'Example 1')
+
+
+ def test_example_two(self):
+ self.assertEqual(decode("1115"), ["AAAE", "AAAO", "AKE", "KAE", "KO"], 'Example 2')
+
+
+ def test_example_three(self):
+ self.assertEqual(decode("127"), ["ABG", "LG"], 'Example 3')
+
+
+if __name__ == "__main__":
+ main(verbosity=2)