aboutsummaryrefslogtreecommitdiff
path: root/challenge-287/zapwai/python/ch-1.py
diff options
context:
space:
mode:
authorDavid Ferrone <zapwai@gmail.com>2024-09-16 12:02:14 -0400
committerDavid Ferrone <zapwai@gmail.com>2024-09-16 12:02:14 -0400
commit3e3e9530a265cb3f549a3556bb78ffdcb1023650 (patch)
tree0ff6a6be7fb3e633fa486069899c8df2df046785 /challenge-287/zapwai/python/ch-1.py
parenteae3cd347219654833096d39e152c603f15e7292 (diff)
downloadperlweeklychallenge-club-3e3e9530a265cb3f549a3556bb78ffdcb1023650.tar.gz
perlweeklychallenge-club-3e3e9530a265cb3f549a3556bb78ffdcb1023650.tar.bz2
perlweeklychallenge-club-3e3e9530a265cb3f549a3556bb78ffdcb1023650.zip
Week 287
Diffstat (limited to 'challenge-287/zapwai/python/ch-1.py')
-rw-r--r--challenge-287/zapwai/python/ch-1.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/challenge-287/zapwai/python/ch-1.py b/challenge-287/zapwai/python/ch-1.py
new file mode 100644
index 0000000000..d3764062d6
--- /dev/null
+++ b/challenge-287/zapwai/python/ch-1.py
@@ -0,0 +1,49 @@
+import re
+def proc(mystr) :
+ print( "Input:", mystr)
+ mylen = len( mystr )
+ len_diff = 0
+ if mylen < 6:
+ len_diff = 6 - mylen
+ elif mylen > 20:
+ len_diff = mylen - 20
+ l = list(mystr)
+ lengths = []
+ hits = 0
+ for i in range(mylen - 1):
+ if l[i] == l[i+1]:
+ hits += 1
+ else :
+ if hits > 1 :
+ lengths.append(1+hits)
+ hits = 0
+ if hits > 1 :
+ lengths.append(1+hits)
+ steps = 0
+ for l in lengths :
+ steps += int(l/3)
+ lflag = 1
+ uflag = 1
+ dflag = 1
+ if re.search('[a-z]',mystr):
+ lflag = 0
+ if re.search('[A-Z]',mystr):
+ uflag = 0
+ if re.search('\d',mystr):
+ dflag = 0
+ tally = lflag + uflag + dflag
+ out_val = len_diff + steps
+ if out_val < tally :
+ out_val += tally - out_val
+ print( "Output: ", out_val)
+
+mystr = "a"
+proc(mystr)
+mystr = "aB2"
+proc(mystr)
+mystr = "PaaSW0rd"
+proc(mystr)
+mystr = "turbbbbot"
+proc(mystr)
+mystr = "111"
+proc(mystr)