Created
August 25, 2014 08:35
-
-
Save yuheiomori/b3dd860c7f1dda5978de to your computer and use it in GitHub Desktop.
First Non-Repeated Character (CodeEval) in Python 3.x
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
# coding=utf-8 | |
import sys | |
def get_first_non_repeated_character(s): | |
first_idx_of_non_repeated_character = list(map(lambda x: s.count(x), s)).index(1) | |
return s[first_idx_of_non_repeated_character] | |
def main(): | |
with open(sys.argv[1], "r") as f: | |
for line in f: | |
print(get_first_non_repeated_character(line.rstrip())) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment