Repository navigation
yuuki's research
< yuuki
Generating all possible strings over a given alphabet is difficult. I don't know what algorithm to use. In Python, you can use itertools.product in a simple case:
from itertools import product
MAX_LENGTH = 6
alphabet = (
"a", "b", "c", "d", "e", "f", "g",
"h", "i", "j", "k", "l", "m", "n",
"o", "p", "q", "r", "s", "t", "u",
"v", "w", "x", "y", "z",
)
for length in range(1, MAX_LENGTH + 1):
for chars in product(alphabet, repeat=length):
print("".join(chars))
# Output:
# a
# b
# ...
# z
# aa
# ab
# ...
# zz
# aaa
# ...
# zzzzzzTotal number of strings
There are 26 strings from "a" to "z", and
In general, the sum of the first
The following are 44 of the Japanese alphabet (gojūon) written in rōmaji. Including "n" causes collisions; "na", "ni", "nu", etc. are generated twice.
alphabet = (
"a", "i", "u", "e", "o",
"ka", "ki", "ku", "ke", "ko",
"sa", "shi", "su", "se", "so",
"ta", "chi", "tsu", "te", "to",
"na", "ni", "nu", "ne", "no",
"ha", "hi", "fu", "he", "ho",
"ma", "mi", "mu", "me", "mo",
"ya", "yu", "yo",
"ra", "ri", "ru", "re", "ro",
"wa",
)The number of rōmaji strings of length
with initial conditions
| 1 | 5 | 26 |
| 2 | 61 | 676 |
| 3 | 488 | 17,576 |
| 4 | 4,651 | 456,976 |
| 5 | 41,006 | 11,881,376 |
| 6 | 373,930 | 308,915,776 |
When you are at
However, when you are at
What is the formula to find the bot's position
Answer
When
When
We see that
Therefore,
🧸 Content is available under CC BY 4.0 unless otherwise noted.