Created
August 22, 2015 21:03
-
-
Save paulohrpinheiro/9bd3f1d53de26f53882c to your computer and use it in GitHub Desktop.
Programa final com o sortedcontainers.
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
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