diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2022-12-06 18:12:50 +0000 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2022-12-06 18:12:50 +0000 |
| commit | 877aa93cb4c06ac54d59e87fe26864b23f092321 (patch) | |
| tree | 28913696978dce143dbc4c61b8f7d4b26afeede4 /challenge-194/eric-cheung/python/ch-2.py | |
| parent | 8b1d1b4780157df141833a9d82da510d6238ab83 (diff) | |
| download | perlweeklychallenge-club-877aa93cb4c06ac54d59e87fe26864b23f092321.tar.gz perlweeklychallenge-club-877aa93cb4c06ac54d59e87fe26864b23f092321.tar.bz2 perlweeklychallenge-club-877aa93cb4c06ac54d59e87fe26864b23f092321.zip | |
- Added guest contributions by Eric Cheung.
Diffstat (limited to 'challenge-194/eric-cheung/python/ch-2.py')
| -rwxr-xr-x | challenge-194/eric-cheung/python/ch-2.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/challenge-194/eric-cheung/python/ch-2.py b/challenge-194/eric-cheung/python/ch-2.py new file mode 100755 index 0000000000..8d04f9bf27 --- /dev/null +++ b/challenge-194/eric-cheung/python/ch-2.py @@ -0,0 +1,24 @@ +
+## strInput = "abbc" ## Example 1
+## strInput = "xyzyyxz" ## Example 2
+strInput = "xzxz" ## Example 3
+
+arrStr = [*strInput]
+arrUniqStr = list(set(arrStr))
+
+arrCount = []
+arrUniqCount = []
+
+for charLoop in arrUniqStr:
+ arrCount.append(arrStr.count(charLoop))
+
+## print (arrCount)
+
+arrUniqCount = list(set(arrCount))
+
+if len(arrUniqCount) == 1 or len(arrUniqCount) > 2:
+ print ("0")
+elif abs(arrUniqCount[0] - arrUniqCount[1]) == 1:
+ print ("1")
+else:
+ print ("0")
|
