aboutsummaryrefslogtreecommitdiff
path: root/challenge-105
diff options
context:
space:
mode:
authorPaulo Custodio <pauloscustodio@gmail.com>2021-11-09 15:36:43 +0000
committerPaulo Custodio <pauloscustodio@gmail.com>2021-11-09 15:36:43 +0000
commit30d3fb62781e045bca559f4c4b7b30a646b2e20f (patch)
tree9bb821331974c62aa2bdf4a2f97e379cdfdda6bc /challenge-105
parent5304a23d00a022c5e3ed05ec4eecb3b2fa2a0828 (diff)
downloadperlweeklychallenge-club-30d3fb62781e045bca559f4c4b7b30a646b2e20f.tar.gz
perlweeklychallenge-club-30d3fb62781e045bca559f4c4b7b30a646b2e20f.tar.bz2
perlweeklychallenge-club-30d3fb62781e045bca559f4c4b7b30a646b2e20f.zip
Add Python solution to challenge 105
Diffstat (limited to 'challenge-105')
-rw-r--r--challenge-105/paulo-custodio/Makefile2
-rw-r--r--challenge-105/paulo-custodio/perl/ch-1.pl2
-rw-r--r--challenge-105/paulo-custodio/perl/ch-2.pl2
-rw-r--r--challenge-105/paulo-custodio/python/ch-1.py29
-rw-r--r--challenge-105/paulo-custodio/python/ch-2.py45
-rw-r--r--challenge-105/paulo-custodio/test.pl4
6 files changed, 78 insertions, 6 deletions
diff --git a/challenge-105/paulo-custodio/Makefile b/challenge-105/paulo-custodio/Makefile
new file mode 100644
index 0000000000..c3c762d746
--- /dev/null
+++ b/challenge-105/paulo-custodio/Makefile
@@ -0,0 +1,2 @@
+all:
+ perl ../../challenge-001/paulo-custodio/test.pl
diff --git a/challenge-105/paulo-custodio/perl/ch-1.pl b/challenge-105/paulo-custodio/perl/ch-1.pl
index c6ef0fbb89..09238281d9 100644
--- a/challenge-105/paulo-custodio/perl/ch-1.pl
+++ b/challenge-105/paulo-custodio/perl/ch-1.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
# Challenge 105
#
diff --git a/challenge-105/paulo-custodio/perl/ch-2.pl b/challenge-105/paulo-custodio/perl/ch-2.pl
index 683584cdbd..be883d4e89 100644
--- a/challenge-105/paulo-custodio/perl/ch-2.pl
+++ b/challenge-105/paulo-custodio/perl/ch-2.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
# Challenge 105
#
diff --git a/challenge-105/paulo-custodio/python/ch-1.py b/challenge-105/paulo-custodio/python/ch-1.py
new file mode 100644
index 0000000000..fe52a1081e
--- /dev/null
+++ b/challenge-105/paulo-custodio/python/ch-1.py
@@ -0,0 +1,29 @@
+#!/usr/bin/env python3
+
+# Challenge 105
+#
+# TASK #1 > Nth root
+# Submitted by: Mohammad S Anwar
+# You are given positive numbers $N and $k.
+#
+# Write a script to find out the $Nth root of $k. For more information, please
+# take a look at the wiki page.
+#
+# Example
+# Input: $N = 5, $k = 248832
+# Output: 12
+#
+# Input: $N = 5, $k = 34
+# Output: 2.02
+
+import sys
+
+def round(n):
+ ROUND_FACTOR = 10000
+ result = int(n*ROUND_FACTOR+0.5)/ROUND_FACTOR
+ if int(result)==result:
+ result = int(result)
+ return result
+
+n, k = int(sys.argv[1]), int(sys.argv[2])
+print(round(k ** (1/n)))
diff --git a/challenge-105/paulo-custodio/python/ch-2.py b/challenge-105/paulo-custodio/python/ch-2.py
new file mode 100644
index 0000000000..e074ad3185
--- /dev/null
+++ b/challenge-105/paulo-custodio/python/ch-2.py
@@ -0,0 +1,45 @@
+#!/usr/bin/env python3
+
+# Challenge 105
+#
+# TASK #2 > The Name Game
+# Submitted by: Mohammad S Anwar
+# You are given a $name.
+#
+# Write a script to display the lyrics to the Shirley Ellis song The Name Game.
+# Please checkout the wiki page for more information.
+#
+# Example
+# Input: $name = "Katie"
+# Output:
+#
+# Katie, Katie, bo-batie,
+# Bonana-fanna fo-fatie
+# Fee fi mo-matie
+# Katie!
+
+import sys
+import re
+
+name = sys.argv[1]
+end = re.sub(r"^[bcdfghjklmnpqrstvwxyz]", "", name, flags=re.IGNORECASE).lower()
+
+if re.search(r"^b", name, flags=re.IGNORECASE):
+ b = ""
+else:
+ b = "b"
+
+if re.search(r"^f", name, flags=re.IGNORECASE):
+ f = ""
+else:
+ f = "f"
+
+if re.search(r"^m", name, flags=re.IGNORECASE):
+ m = ""
+else:
+ m = "m"
+
+print(f"{name}, {name}, bo-{b}{end},")
+print(f"Bonana-fanna fo-{f}{end}")
+print(f"Fee fi mo-{m}{end}")
+print(f"{name}!")
diff --git a/challenge-105/paulo-custodio/test.pl b/challenge-105/paulo-custodio/test.pl
deleted file mode 100644
index ba6c37260b..0000000000
--- a/challenge-105/paulo-custodio/test.pl
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/usr/bin/env perl
-use Modern::Perl;
-use Test::More;
-require '../../challenge-001/paulo-custodio/test.pl';