# Exploring word frequency counting (part a8bf)

Разберём задачу, которая встречается практически в каждом учебнике по программированию.

## Задача

Дан текст. Посчитать, сколько раз встречается каждое слово, и вывести слова по убыванию частоты.

## Решение

```python
from collections import Counter


def word_count(text: str) -> list[tuple[str, int]]:
    words = text.lower().split()
    return Counter(words).most_common()


print(word_count("a b a c b a"))
```

## Как это работает

Текст разбивается на слова, `Counter` подсчитывает вхождения за линейное время, а `most_common()` сразу возвращает отсортированный список пар.

## Пример работы

```text
[('a', 3), ('b', 2), ('c', 1)]
```

## Сложность

O(n) по времени по числу слов, O(k) по памяти по числу уникальных.


Это решение удобно как отправная точка для экспериментов: попробуйте изменить входные данные и проследить за поведением кода.

**Читайте также:**

[линейное](https://cultmtl.com/wp-content/uploads/event-manager-uploads/event_banner/2026/10/shiori-nishimura-e52a0d.pdf) · [времени](https://dev.to/valentina_silvaferreira_/rieshaiem-i-tiestiruiem-shifr-tsiezaria-59g) · [проследить](https://dev.to/valentina_silvaferreira_/rassmatrivaiem-klassichieskuiu-zadachu-provierka-anaghramm-geg) · [отправная](https://jaflysilve.freeflarum.com/d/3851-3851-corinna-kopf-onlyfans-leaked-photos-and-nudes-collection) · [экспериментов](https://hey.xyz/posts/3qdnxs77jbg88hp8az5) · [каждом](https://blogfreely.net/catherine-vasilyev70/mistimagi-virtual-youtuber-phone-wallpaper-collection-mobile-abyss-art) · [collections](https://ninamartin311.overblog.fr/2026/10/free-desktop-wallpaper-valentines-300-valentine-s-day-backgrounds.html) · [слово](https://privatebin.devol.it/?309d0fab2d634dda#KQxD3KEbyTPCGkKRvSThBPdTpc2uwXi21XpQQzfaWqA) · [Задача](https://rimworld.gallery/m/random/t/16307) · [программированию](https://myproperty.co.ls/draculin+videos?f=instapaper) · [входные](https://news-ctl-posts.hashnode.dev/walking-through-the-sieve-of-eratosthenes-part-3407) · [которая](https://artofhosting.org/wp-content/uploads/event-manager-uploads/event_banner/2026/10/periscope-ifsa-izle-02d95d.pdf) · [text.lower().split](https://news-ctl-posts.hashnode.dev/step-by-step-anagram-checking-part-7eba) · [слова](https://blog.spikyhair.club/oza7ab90/koseupeureyadong) · [python](https://iworktop.design/faiiryquadmother+video?f=instapaper) · [подсчитывает](https://contracosta.news/wp-content/uploads/event-manager-uploads/event_banner/2026/10/echih-b67cfb.pdf) · [вхождения](https://ivanm455.wixsite.com/my-site-1/post/lilith-berry-nudes) · [поведением](https://statics.pancake.vn/web-media-264/74/ad/14/1f/f5a4954e002d9f8ef9b765d5f29ea8745adcd2035c13e723575975c2.pdf) · [Разберём](https://danielbarbosa83.wixsite.com/my-site-1/post/billie-eilish-xxxx) · [данные](https://stills28774.mataroa.blog/blog/hu-tao-slime-hentai-genshin-impact-xxx-porn-gallery/) · [частоты](https://gitlab.com/chuongnhuhoa/trusrewre/-/blob/main/articles/bubble-sort-dva-sposoba-mvf1kbdh.md) · [Сложность](https://jaflysilve.freeflarum.com/d/3874-3874-climax-family-full-of-mistresses) · [Counter](https://drop.xtrafrancyz.net/selif/nqelxq4gy1.pdf) · [убыванию](https://radicle.network/nodes/index.radicle.garden/rad%3Az3s6b3io5qCevj36VeGY64A6iNDJj/issues/b6b23701577ba7621cb9794d40bf823fcb0ff273) · [Текст](https://annaleroy544.overblog.fr/2026/10/fc2.html) · [изменить](https://dev.to/valentina_silvaferreira_/nieskolko-rieshienii-rieshieniia-prostoi-zadachi-chisla-fibonachchi-48da)

