Q2b.cpp
Q2b.cpp
#include <random>
#include <vector>
#include <string>
#include <algorithm>
#include <ctime>
string random_word(int L) {
std::string s;
for (int i = 0; i < L; ++i) {
s.push_back('a' + std::random_device()() % 26);
}
return s;
}
string sorted_a = a;
string sorted_b = b;
std::sort(sorted_a.begin(), sorted_a.end());
std::sort(sorted_b.begin(), sorted_b.end());
cout << "Number of anagram pairs: " << count << endl;
}
int main() {
srand(time(0));
vector<string> v;
for (int i = 0; i < 90000; ++i) {
int L = (rand() % 20) + 1;
v.push_back(random_word(L));
}
count_anagrams(v);