Moh*_*rek 0 c# math probability
嗨,我昨天已经问了这个问题而且因为不被理解而被关闭了,所以我会尝试更具体,因为这次我可以.所以情况就是这样.
1.我有3个字符:字符数组中的A,B,C如下:
char[] characters = {'A', 'B', 'C'};
Run Code Online (Sandbox Code Playgroud)
2.在枚举这3个字符的所有可能匹配时,我得到例如以下内容:
Text = A
tries = 1
indexes = characters[0]
------------
Text = B
tries = 2
indexes = characters[1]
------------
Text = C
tries = 3
indexes = characters[2]
------------
Text = AA
tries = 4
indexes = characters[0] characters[0]
------------
Text = AB
tries = 5
indexes = characters[0] characters[1]
------------
Text = AC
tries = 6
indexes = characters[0] characters[2]
------------
Text = BA
tries = 7
indexes = characters[1] characters[0]
------------
Text = BB
tries = 8
indexes = characters[1] characters[1]
------------
Text = BC
tries = 9
indexes = characters[1] characters[2]
------------
Text = CA
tries = 10
indexes = characters[2] characters[0]
------------
Text = CB
tries = 11
indexes = characters[2] characters[1]
------------
Text = CC
tries = 12
indexes = characters[2] characters[2]
Run Code Online (Sandbox Code Playgroud)
3.现在给出一定的尝试次数,我们可以在这个特定的尝试中得到索引的数量吗?例如,在尝试号码10的意思下,尝试文本是CA(如上所示),因为索引是字符[2]和字符[0],那么是否有一个数学方程式来知道这些索引数字的尝试次数?
谢谢
我们可以在这个特定的尝试中获得索引的数量
对于任何给定数量的字母,您只需计算基数为3的数字.因此,只需将十进制转换为base-3,然后再返回.
为了确定较少的字符串长度有多少种可能性:有3 ^ n种不同的长度字符串n使用3个字母.