aboutsummaryrefslogtreecommitdiff
path: root/challenge-207/robert-dicicco/python
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-207/robert-dicicco/python')
-rw-r--r--challenge-207/robert-dicicco/python/ch-1.py47
-rw-r--r--challenge-207/robert-dicicco/python/ch-2.py37
2 files changed, 84 insertions, 0 deletions
diff --git a/challenge-207/robert-dicicco/python/ch-1.py b/challenge-207/robert-dicicco/python/ch-1.py
new file mode 100644
index 0000000000..850c89b0ce
--- /dev/null
+++ b/challenge-207/robert-dicicco/python/ch-1.py
@@ -0,0 +1,47 @@
+#/usr/bin/env python
+'''
+--------------------------------------
+AUTHOR: Robert DiCicco
+DATE : 2023-03-06
+Challenge 207 Keyboard Word ( Python )
+--------------------------------------
+'''
+
+rows = ["qwertyuiop", "asdfghjkl", "zxcvbnm"]
+words = ["Hello", "Alaska", "Dad", "Peace"], ["OMG", "Bye"]
+flag = 0
+
+def CheckLetters(w):
+ ln = len(w)
+ for j in range(3):
+ flag = 0
+ for x in range(ln):
+ if (w[x] in rows[j]):
+ pass
+ else:
+ flag = 1
+ if flag == 0 :
+ print("\t",w)
+ flag = 0
+
+for wds in words:
+ print("Input: @words = ",wds)
+ print("Output: ")
+ ln = len(wds)
+ for j in range(0,ln):
+ CheckLetters(wds[j].lower())
+ print(" ")
+
+'''
+--------------------------------------
+SAMPLE OUTPUT
+python .\KeyboardWord.py
+Input: @words = ['Hello', 'Alaska', 'Dad', 'Peace']
+Output:
+ alaska
+ dad
+
+Input: @words = ['OMG', 'Bye']
+Output:
+
+'''
diff --git a/challenge-207/robert-dicicco/python/ch-2.py b/challenge-207/robert-dicicco/python/ch-2.py
new file mode 100644
index 0000000000..4327ca5d04
--- /dev/null
+++ b/challenge-207/robert-dicicco/python/ch-2.py
@@ -0,0 +1,37 @@
+#!/usr/bin/env python
+'''
+----------------------------------
+AUTHOR: Robert DiCicco
+DATE : 2023-03-07
+Challenge 207 H-Index ( Python )
+==================================
+'''
+citations = [10,8,5,4,3],[25,8,5,3,3]
+
+def CalcIndex(c):
+ ln = len(c)
+ offset = ln - 1
+ pos = ln
+ while offset >= 0 :
+ if c[offset] >= pos :
+ print("Output: ",pos,"\n")
+ return
+ else :
+ offset -= 1
+ pos -= 1
+
+for c in citations:
+ print("Input: @citations =",c)
+ CalcIndex(c)
+
+'''
+----------------------------------
+SAMPLE OUTPUT
+python .\HIndex.py
+Input: @citations = [10, 8, 5, 4, 3]
+Output: 4
+
+Input: @citations = [25, 8, 5, 3, 3]
+Output: 3
+----------------------------------
+'''