Last active
December 13, 2022 16:25
-
-
Save yogaxpto/ecb18370af406c433a9fff18f60b6547 to your computer and use it in GitHub Desktop.
Viz.ai live code challenge
This file contains 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
input_: str = """Certainly an Englishman, it was more doubtful whether Phileas Fogg was a Londoner. He was never seen on ’Change, nor at the Bank, nor in the counting-rooms of the “City”; no ships ever came into London docks of which he was the owner; he had no public employment; he had never been entered at any of the Inns of Court, either at the Temple, or Lincoln’s Inn, or Gray’s Inn; nor had his voice ever resounded in the Court of Chancery, or in the Exchequer, or the Queen’s Bench, or the Ecclesiastical Co""" | |
def reverse(string: str) -> str: | |
if len(string) <= 1: | |
return string | |
return string[-1] + reverse(string[:-1]) | |
def occurrences(string: str) -> dict[str, int]: | |
list_words = string.split(' ') | |
return {key: list_words.count(key) for key in set(list_words)} | |
if __name__ == '__main__': | |
print(reverse('hello world')) | |
print(occurrences(input_)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment