Markov chain: finding the most probable path
A simple Markov chain based text generator selects the next word based on the probabilities of which word comes after each word (transition probabilities). This table was extracted by counting word pairs (bigrams) from a small corpus of texts about the weather.
States (words): QUYOSH, BULUT, YOMGIR, SHAMOL, TUMAN. The following table shows the satr -> ustun transition probabilities (the sum of each row is 1.0):
| from \ to | QUYOSH | BULUT | YOMGIR | SHAMOL | TUMAN |
|---|---|---|---|---|---|
QUYOSH | 0.1 | 0.2 | 0.2 | 0.4 | 0.1 |
BULUT | 0.1 | 0.1 | 0.1 | 0.4 | 0.3 |
YOMGIR | 0.3 | 0.1 | 0.3 | 0.1 | 0.2 |
SHAMOL | 0.2 | 0.2 | 0.2 | 0.3 | 0.1 |
TUMAN | 0.1 | 0.2 | 0.2 | 0.4 | 0.1 |
The generator starts with the word QUYOSH and makes 3 consecutive transitions (resulting in a path of 4 words in total).
Out of all possible paths, find the path with the highest overall probability (i.e. the one where the product of all transition probabilities in the path is the largest).
Place the found path (including the starting word, in uppercase, separated by underscores _) inside the flag:
BAYROQ{41_MARKOV_<SO'Z1>_<SO'Z2>_..._<SO'ZN>}