单词的组合…功率集
Combinations of Words...Power Set?
我想破解一个我忘记的密码。我知道密码中可能使用的所有单词,但有些可能使用或不使用。例如:HarryMetSally可能是密码,但我可能会使用"Harry"Billy"Sally"answers"Met"的单词列表来组合破解。
如果我有16个单词,但可能使用了14-16个单词,我如何在c++或Python中编写16个单词(或20,25,30个单词)随机连接在一起并一次使用1个或2-16个单词,甚至不以相同的顺序使用。
的例子:
文字:Harry Billy Sally Met
结合例子:
哈利比利SallyBillyBillySallyHarryMetSallyHarrySallyMet
我在网上广泛搜索,也尝试过Excel论坛。指导吗?
你说随机…
#include <iostream>
#include "stdlib.h"
#include "time.h"
#define NUM_WORDS 3
char* words[NUM_WORDS] = {
"Foo",
"Bar",
"Baz"
};
typedef unsigned long long ULL;
ULL fact(ULL n, ULL lowerLimit = 1)
{
if (n <= lowerLimit) return 1;
return n * fact(n - 1);
}
int main()
{
srand(time(NULL));
// I can try single words all by myself, so start at 2 or more words
for (int nWords = 2; nWords <= NUM_WORDS; ++nWords)
{
// calculate the number of possibilities
// but since it's random, triple it for good measure
ULL nIters = fact(NUM_WORDS, NUM_WORDS - nWords) * 3;
for (ULL iter = 0; iter < nIters; ++iter)
{
for (int iterWord = 0; iterWord < nWords; ++iterWord)
{
int ix = rand() % NUM_WORDS;
std::cout << words[ix];
}
std::cout << std::endl;
}
}
return 0;
}
相关文章:
- 如何在OMNET++中指定与命令行参数组合的输出文件名
- 可组合的lambda/std::函数与std::可选
- 如何将两个不同矢量的同一位置的两个元素组合在一起
- 混合组合和继承的C++问题
- 我需要将多个函数组合为一个函数
- 构建可组合有向图(扫描仪生成器的汤普森构造算法)
- 通过组合不同的类型来创建唯一的id
- 用常见虚拟函数实现的任意组合来实现派生类的正确方法是什么
- 模板元编程:如何将参数包组合成新的参数包
- 检查向量是否具有所有可能的字符组合
- 如何在加密++中将两个源组合成新的源
- 根中的组合
- 更改 C++ 中的组合分类变量
- 错误:(-210:不支持的格式或格式组合)功能'create'中的硬件视频解码器不支持视频源
- 组合字符串不适用于 libCurl,C++
- 测试两个类型列表中的所有组合
- 将多个 for 循环组合成单个迭代器
- 如何从组合指数中找到仓位
- 防止组合框被关闭
- 单词的组合…功率集