Last active
May 1, 2021 14:51
-
-
Save mentix02/d1a86a82ec1f1034e2d1dfe22d6b1aaa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Dict | |
from pprint import pprint | |
def parse_dataset(filename: str) -> Dict[str, str]: | |
data = {} | |
with open(filename) as f: | |
for line in f: | |
line = line.rstrip() | |
if line.startswith(">"): | |
label = line[1:] | |
data[label] = "" | |
else: | |
print(line) | |
data[label] += line | |
return data | |
if __name__ == "__main__": | |
data = parse_dataset(input("path to dataset\n> ")) | |
pprint(data) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
VOWELS = {'a', 'e', 'i', 'o', 'u'} | |
def is_vowel(c: str) -> bool: | |
return c in VOWELS | |
def longest_sub_vowel_str(s: str) -> str: | |
idx = 0 | |
possible_longest = curr_longest = "" | |
while idx < len(s): | |
if is_vowel(s[idx]): | |
possible_longest = "" | |
while is_vowel(s[idx]) and idx < len(s): | |
possible_longest += s[idx] | |
idx += 1 | |
if len(possible_longest) > len(curr_longest): | |
curr_longest = possible_longest | |
idx += 1 | |
return curr_longest |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment