Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need help with a semi-isogram code that counts the number of consonants and vowe

ID: 3720413 • Letter: N

Question

Need help with a semi-isogram code that counts the number of consonants and vowels in a word and determines if it is an isogram, but vowels are counted together as one.

#include <iostream>

#include <list>

#include <locale> // std::locale and std::tolower

#include <string>

#include <unordered_set>

// This hashing function should take the given character c and return an integer

// representing the hash value. This will be computed by the position of a-z,

// where a=>0, b=>1, and so on.

size_t CustomHasher::operator()(const char& c) const {

// Your code goes here

}

// This function should populate the provided multiset object (ms). For each

// character in the string s, it should insert that character (lower-cased) into

// ms. The provided string s will only contain the letters A-Z and a-z, and you

// do not need to validate the string. The resulting multiset should contain a

// bucket for each letter a-z and the size of each bucket (i.e. the number of

// elements in that specific bucket) will reflect the number of times the

// corresponding letter appears in string s. The multiset object ms will be

// guaranteed to have at least 26 buckets before it is sent to this function.

void populate_multiset(const string& s,

   unordered_multiset* ms) {

// Your code goes here

}

// This function should return true if the data populated in the multiset (ms)

// represents a string that is an Isogram. For this project, an Isogram is where

// each letter appears the same number of times (not necessarily just once). An

// additional twist is that all vowels (a, e, i, o, u) are treated as the same

// letter. Thus, the strings "abc", "aabb", and "abbi" should return true, while

// the strings "abb" and "aeb" would return false. The output parameter 'count'

// should be populated with the number of times that the same letters appeared

// and will only be queried if the string was an Isogram. So, in the examples

// above for "abc", "aabb", and "abbi", the count would be 1, 2, and 2

// respectively.

bool is_semi_isogram(const unordered_multiset& ms,

   unsigned int* count) {

// Your code goes here

}

And also, this is my .h file:

struct CustomHasher {

size_t operator()(const char& c) const;

};

void populate_multiset(const string& s,

   unordered_multiset<char, CustomHasher>* ms);

bool is_semi_isogram(const unordered_multiset<char, CustomHasher>& ms,

   unsigned int* count);

Explanation / Answer

size_t CustomHasher::operator()(const char& c) const {

// Your code goes here

Size_t res,compt;

compt = c;

compt=compt-97;

return compt;

}

void populate_multiset(const string& s,

   unordered_multiset* ms) {

// Your code goes here

Size_t loc,cal;

For(i=0;i<string.length(s);i++)

{

string.copy(cal,i,1);

if(cal>=65 && cal <= 91)

cal+=32;

cal=cal-97;

loc=ms[cal];

ms[cal]=++loc;

}

}

bool is_semi_isogram(const unordered_multiset& ms,

   unsigned int* count) {

// Your code goes here

Int count=0;

//code for making a e i o u as a single char

ms[0]=ms[0]+ms[5];//for e

ms[5] = 0;

ms[0]=ms[0]+ms[9];/for i

ms[9]=0;

ms[0]=ms[0]+ms[15]; //for o

ms[15]=0;

ms[0]=ms[0]+ms[21];//for u

ms[21]=0;

For(i=0;i<ms.end;i++)

{

If(ms[i]==ms[i+1])

Count =1;

}

if( count ==1)

return True;

else

return False;

}