Skip to content

Instantly share code, notes, and snippets.

@paulohrpinheiro
Created August 22, 2015 21:03
Show Gist options
  • Save paulohrpinheiro/9bd3f1d53de26f53882c to your computer and use it in GitHub Desktop.
Save paulohrpinheiro/9bd3f1d53de26f53882c to your computer and use it in GitHub Desktop.
Programa final com o sortedcontainers.
import sys
import sortedcontainers
words = sortedcontainers.SortedSet()
plain_text = list()
codded_text= list()
# read content
plain_text = [l.strip().split() for l in sys.stdin]
# build a word list from content
for line in plain_text:
[words.add(w) for w in line]
# in sortedcontainers, SortedSet have an index method :)
# build codded content
for line in plain_text:
codded_text.append([words.index(w) for w in line])
# how many words?
print(len(words))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment