News for hackers. Stuff that matters.
Re:To apply, solve the following... are you kidding? by phektus on Friday September 30, 2011 @10:22AM (#3057099)

  corpus = """

  yellow

  tooth

  """

  for line in corpus.splitlines():

    for letter in line:

      if line.count(letter) == 1:

        print letter

        break
Re:To apply, solve the following... are you kidding? by achompas on Friday September 30, 2011 @11:55AM (#3057441)
My first pass (assumes input file is an arg):

    import sys

    def first_unique(word):
        if len(word) == 0:
            return "EOF"
        for i in range(0, len(word)-1):
            return word[i] if word[i] != word[i+1]
        return "NA"

    def main():
        with open(sys.argv[1],'r') as f:
            print first_unique(f.readline())
Re:To apply, solve the following... are you kidding? by epicureanideal on Saturday October 01, 2011 @03:59PM (#3060952)
This seems pretty inefficient, as it seems that line.count would be checking the whole line for how many times the letter appears. However, if you're solving in Python I guess efficiency is not really top priority anyway, and they also didn't specify a language or efficiency.
Re:To apply, solve the following... are you kidding? by achompas on Friday September 30, 2011 @12:08PM (#3057491)
Trying functional:

    import sys

    with open(sys.argv[1], 'r') as f:
        word = f.readline()
        try:
            print filter(lambda x: word.count(x) == 1, word)[0]
        except IndexError:
            print ""
Re:To apply, solve the following... are you kidding? by amikazmi on Thursday October 13, 2011 @09:54AM (#3107151)

  IO.readlines(file).each do |w|
    puts w.split(//).find { |c| w.count(c) == 1 }
  end