aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorealvar3z <55966724+ealvar3z@users.noreply.github.com>2022-12-02 17:53:18 -0800
committerealvar3z <55966724+ealvar3z@users.noreply.github.com>2022-12-02 17:53:18 -0800
commit65cf1411344711377714c7247e612a2e92b06861 (patch)
tree7781838122a45549fdba18c33676e66a1535b8ed
parenta2e83078f174858d6f30ac851ab63f1f2cc18fba (diff)
downloadperlweeklychallenge-club-65cf1411344711377714c7247e612a2e92b06861.tar.gz
perlweeklychallenge-club-65cf1411344711377714c7247e612a2e92b06861.tar.bz2
perlweeklychallenge-club-65cf1411344711377714c7247e612a2e92b06861.zip
go & python solutions
-rw-r--r--challenge-193/ealvar3z/go/ch-1.go17
-rw-r--r--challenge-193/ealvar3z/python/ch-1.py15
-rw-r--r--challenge-193/ealvar3z/python/ch-2.py21
3 files changed, 53 insertions, 0 deletions
diff --git a/challenge-193/ealvar3z/go/ch-1.go b/challenge-193/ealvar3z/go/ch-1.go
new file mode 100644
index 0000000000..9dafd63265
--- /dev/null
+++ b/challenge-193/ealvar3z/go/ch-1.go
@@ -0,0 +1,17 @@
+package main
+
+import "fmt"
+
+func main() {
+ bitStr(2)
+ print("\n")
+ bitStr(3)
+}
+
+func bitStr(n int) {
+ limit := 1 << n
+ for i := 0; i < limit; i++ {
+ value := i
+ fmt.Printf("%.*b\n", n, value)
+ }
+}
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())