aboutsummaryrefslogtreecommitdiffstats
path: root/1704
diff options
context:
space:
mode:
Diffstat (limited to '1704')
-rwxr-xr-x1704/main.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/1704/main.py b/1704/main.py
new file mode 100755
index 0000000..3fb2870
--- /dev/null
+++ b/1704/main.py
@@ -0,0 +1,30 @@
+#!/usr/bin/env python
+
+
+class Solution:
+ def halvesAreAlike(self, s: str) -> bool:
+ vowels = ["a", "e", "i", "o", "u", "A", "E", "I", "O", "U"]
+ length = len(s) // 2
+ first = 0
+ second = 0
+ for i in range(0, length):
+ if s[i] in vowels:
+ first += 1
+
+ if s[length + i] in vowels:
+ second += 1
+
+ if first == second:
+ return True
+ return False
+
+
+def main():
+ solution = Solution()
+ print(solution.halvesAreAlike("book"))
+ print(solution.halvesAreAlike("textbook"))
+ print(solution.halvesAreAlike("AbCdEfGh"))
+
+
+if __name__ == "__main__":
+ main()