aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2022-12-03 08:06:15 +0000
committerGitHub <noreply@github.com>2022-12-03 08:06:15 +0000
commitf66907e2fdb8db43cb6f07bd84e71ab34e1eb106 (patch)
treefe3971c02ac735fb0b37c062dd095faa43c23fdb
parent6a323df80491e39ba4e3ed0449f38e06d161f7f5 (diff)
parent802f5ca2a1bd72fb8286c14ee79c91086ff1ef34 (diff)
downloadperlweeklychallenge-club-f66907e2fdb8db43cb6f07bd84e71ab34e1eb106.tar.gz
perlweeklychallenge-club-f66907e2fdb8db43cb6f07bd84e71ab34e1eb106.tar.bz2
perlweeklychallenge-club-f66907e2fdb8db43cb6f07bd84e71ab34e1eb106.zip
Merge pull request #7192 from ealvar3z/challenge-193
go & python solutions
-rw-r--r--challenge-193/ealvar3z/blog.txt1
-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
4 files changed, 54 insertions, 0 deletions
diff --git a/challenge-193/ealvar3z/blog.txt b/challenge-193/ealvar3z/blog.txt
new file mode 100644
index 0000000000..0c39bed53d
--- /dev/null
+++ b/challenge-193/ealvar3z/blog.txt
@@ -0,0 +1 @@
+https://alvar3z.com/posts/lambdas--printf/
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())