Skip to content

Instantly share code, notes, and snippets.

@yuheiomori
Created August 25, 2014 08:35
Show Gist options
  • Save yuheiomori/b3dd860c7f1dda5978de to your computer and use it in GitHub Desktop.
Save yuheiomori/b3dd860c7f1dda5978de to your computer and use it in GitHub Desktop.
First Non-Repeated Character (CodeEval) in Python 3.x
# 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