aboutsummaryrefslogtreecommitdiff
path: root/challenge-193/ealvar3z/python
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-193/ealvar3z/python')
-rw-r--r--challenge-193/ealvar3z/python/ch-1.py15
-rw-r--r--challenge-193/ealvar3z/python/ch-2.py21
2 files changed, 36 insertions, 0 deletions
diff --git a/challenge-193/ealvar3z/python/ch-1.py b/challenge-193/ealvar3z/python/ch-1.py
new file mode 100644
index 0000000000..54e0da742f
--- /dev/null
+++ b/challenge-193/ealvar3z/python/ch-1.py
@@ -0,0 +1,15 @@
+#!/usr/bin/env python3
+
+
+def bit_str(n):
+ limit = 1 << n
+ for i in range(limit):
+ value = i
+ width = f'0{n}'
+ print(f'{value:{width}b}')
+
+
+if __name__ == "__main__":
+ bit_str(2)
+ print('\n')
+ bit_str(3)
diff --git a/challenge-193/ealvar3z/python/ch-2.py b/challenge-193/ealvar3z/python/ch-2.py
new file mode 100644
index 0000000000..e94157c528
--- /dev/null
+++ b/challenge-193/ealvar3z/python/ch-2.py
@@ -0,0 +1,21 @@
+#!/usr/bin/env python3
+
+
+def odd_str(_list):
+ def diff(x): return [ord(x[i]) - ord(x[i - 1]) for i in range(1, len(x))]
+ _list.sort(key=diff)
+
+ fst = _list[0]
+ snd = _list[1]
+ last = _list[-1]
+
+ return fst if diff(fst) != diff(snd) else last
+
+
+def main():
+ words = ["adc", "wzy", "abc"]
+ print(odd_str(words))
+
+
+if __name__ == "__main__":
+ exit(main())