aboutsummaryrefslogtreecommitdiff
path: root/challenge-220/robert-dicicco/python
diff options
context:
space:
mode:
authorMohammad S Anwar <mohammad.anwar@yahoo.com>2023-06-12 05:17:44 +0100
committerMohammad S Anwar <mohammad.anwar@yahoo.com>2023-06-12 05:17:44 +0100
commite2bcd5b91f30ead0274fca78de01038b4432995b (patch)
treead9068d3c9efe097349ab136ebac3d16aaadbaa8 /challenge-220/robert-dicicco/python
parentb69ae3ee9ee4535d66c3c1cb5c4b8fb3712dd75c (diff)
downloadperlweeklychallenge-club-e2bcd5b91f30ead0274fca78de01038b4432995b.tar.gz
perlweeklychallenge-club-e2bcd5b91f30ead0274fca78de01038b4432995b.tar.bz2
perlweeklychallenge-club-e2bcd5b91f30ead0274fca78de01038b4432995b.zip
- Added solutions by Roger Bell_West.
- Added solutions by Robert DiCicco. - Added solutions by Ulrich Rieke. - Added solutions by Laurent Rosenfeld. - Added solutions by Niels van Dijke. - Added solutions by Simon Proctor. - Added solutions by Mark Anderson. - Added solutions by Peter Meszaros. - Added solutions by W. Luis Mochan. - Added solutions by David Ferrone. - Added solutions by Thomas Kohler. - Added solutions by Stephen G. Lynn. - Added solutions by Peter Campbell Smith. - Added solutions by E. Choroba. - Added solutions by Robbie Hatley. - Added solutions by Jorg Sommrey. - Added solutions by Cheok-Yin Fung. - Added solutions by Robert Ransbottom. - Added solutions by Flavio Poletti. - Added solutions by Jaldhar H. Vyas. - Added solutions by Avery Adams. - Added solutions by Bob Lied. - Added solutions by Athanasius. - Added solutions by Simon Green. - Added solutions by Jan Krnavek. - Added solutions by Lubos Kolouch. - Added solutions by BarrOff. - Added solutions by Solathian. - Added solutions by Matthias Muth.
Diffstat (limited to 'challenge-220/robert-dicicco/python')
-rw-r--r--challenge-220/robert-dicicco/python/ch-1.py38
-rw-r--r--challenge-220/robert-dicicco/python/ch-2.py49
2 files changed, 87 insertions, 0 deletions
diff --git a/challenge-220/robert-dicicco/python/ch-1.py b/challenge-220/robert-dicicco/python/ch-1.py
new file mode 100644
index 0000000000..632e169c46
--- /dev/null
+++ b/challenge-220/robert-dicicco/python/ch-1.py
@@ -0,0 +1,38 @@
+#!/usr/bin/env python
+# ------------------------------------------------
+# AUTHOR: Robert DiCicco
+# DATE : 2023-06-05
+# Challenge 220 Task 1 common Characters ( Python )
+# ------------------------------------------------
+
+words = [["Perl", "Rust", "Raku"], ["love", "live", "leave"]]
+
+alphabet_hash = {}
+
+for wds in words:
+ for char in range(ord('a'), ord('z')+1):
+ alphabet_hash[chr(char)] = 0
+
+ print("Input: @words = ",wds)
+ for wd in wds:
+ wd = wd.lower()
+ for ch in wd:
+ alphabet_hash[ch] += 1
+
+ print("Output: ",end= " ")
+ for i in alphabet_hash:
+ if alphabet_hash[i] >= 3:
+ print(i,end=" ")
+ print("\n")
+
+# ------------------------------------------------
+# SAMPLE OUTPUT
+# python .\CommonChars.py
+
+# Input: @words = ['Perl', 'Rust', 'Raku']
+# Output: r
+
+# Input: @words = ['love', 'live', 'leave']
+# Output: e l v
+
+# ------------------------------------------------
diff --git a/challenge-220/robert-dicicco/python/ch-2.py b/challenge-220/robert-dicicco/python/ch-2.py
new file mode 100644
index 0000000000..550194cb55
--- /dev/null
+++ b/challenge-220/robert-dicicco/python/ch-2.py
@@ -0,0 +1,49 @@
+#!/usr/bin/env python
+# ------------------------------------------
+# AUTHOR: Robert DiCicco
+# DATE : 2023-06-00
+# Challenge 220 Task 2 Squareful ( Python )
+# ------------------------------------------
+import math
+from itertools import permutations
+
+
+myints = [[1,8,17],[1,8,17,19]]
+
+def IsPerfectSquare(number_to_test) :
+ root = math.floor(math.sqrt(number_to_test))
+ if ((root ** 2 ) == number_to_test) :
+ return True;
+ return False;
+
+for intsub in myints:
+ print("Input: @ints = ",intsub)
+ print("OutPut: ",end="")
+ perm = permutations(intsub)
+ for i in list(perm):
+ ln = len(i) - 1
+ tv = 0
+ flag = 0
+ while tv < ln :
+ if IsPerfectSquare(i[tv] + i[tv + 1]) :
+ flag += 1
+ else :
+ flag = 0
+ tv += 1
+ if flag == ln - 1 :
+ print(i,end=" ")
+ print("\n")
+
+#------------------------------------------
+# SAMPLE OUTPUT
+# python .\Squareful.py
+
+# Input: @ints = [1, 8, 17]
+# OutPut: (1, 17, 8) (17, 1, 8)
+
+# Input: @ints = [1, 8, 17, 19]
+# OutPut: (1, 19, 17, 8) (19, 1, 8, 17)
+#------------------------------------------
+
+
+