Занятие 10. Множества

Задача «Количество слов в тексте»


Дан текст: в первой строке записано число строк, далее идут сами строки. Определите, сколько различных слов содержится в этом тексте.

Словом считается последовательность непробельных символов идущих подряд, слова разделены одним или большим числом пробелов или символами конца строки.

Во всех задачах считывайте входные данные через input() и выводите ответ через print().

Войти или зарегистрироваться, чтобы отправлять решения на проверку


Входные данные Правильный ответ Что вывела программа Результат
She sells sea shells on the sea shore;
The shells that she sells are sea shells I'm sure.
So if she sells sea shells on the sea shore,
I'm sure that the shells are sea shore shells.
The other two, slight air, and purging fire,
Are both with thee, wherever I abide,
The first my thought, the other my desire,
These present-absent with swift motion slide.
For when these quicker elements are gone
In tender embassy of love to thee,
My life being made of four, with two alone,
Sinks down to death, oppressed with melancholy.
Until life's composition be recured,
By those swift messengers returned from thee,
Who even but now come back again assured,
Of thy fair health, recounting it to me.
This told, I joy, but then no longer glad,
I send them back again and straight grow sad.
a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a
a b a c a b a d a b a c a b a
Not much chance, completely cut loose from purpose,
He was a young man riding a bus through North Carolina on the way to somewhere.
And it began to snow.
And the bus stopped at a little cafe in the hills and the passengers entered.
And he sat at the counter with the others, and he ordered, the food arrived.
And the meal was particularly good.
And the coffee.
The waitress was unlike the women he had known.
She was unaffected, and there was a natural humor which came from her.
And the fry cook said crazy things.
And the dishwasher in back laughed a good clean pleasant laugh.
And the young man watched the snow through the window.
And he wanted to stay in that cafe forever.
The curious feeling swam through him that everything was beautiful there.
And it would always stay beautiful there.
And then the bus driver told the passengers that it was time to board.
And the young man thought: “I’ll just stay here, I’ll just stay here.”
And then he rose and he followed the others into the bus.
He found his seat and looked at the cafe through the window.
And then the bus moved off, down a curve, downward, out of the hills.
And the young man looked straight forward.
And he heard the other passengers speaking of other things,
or they were reading or trying to sleep.
And they hadn’t noticed the magic.
And the young man put his head to one side,
closed his eyes, and pretended to sleep.
There was nothing else to do,
just to listen to the sound of the engine,
and the sound of the tires
in the snow.