From 935a8c04f2370204581cf27ad9e9e9c7dd998302 Mon Sep 17 00:00:00 2001 From: terminaldweller Date: Thu, 11 Jan 2024 21:39:44 -0500 Subject: 1704 --- 1704/main.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 1704/main.py 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() -- cgit v1.2.3