Skip to content

Commit

Permalink
add word and rating length check for guess
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMoonThatRises committed Apr 11, 2024
1 parent 88097e0 commit cc93634
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,12 @@ int main(int argc, char* argv[])
guess = commandGuesses.begin()->first;
}

if(guess.length() != valids[0].length())
{
std::cout << "Invalid word length of " << guess.length() << ": '" << guess << "'" << std::endl;
return 0;
}

std::transform(guess.begin(), guess.end(), guess.begin(), ::tolower);

if(valids.size() > 1 || valids.size() == 1)
Expand All @@ -777,6 +783,12 @@ int main(int argc, char* argv[])
rating = commandGuesses.begin()->second;
}

if(rating.length() != valids[0].length())
{
std::cout << "Invalid rating length of " << rating.length() << ": '" << rating << "'" << std::endl;
return 0;
}

valids = filter(valids,std::make_pair(guess, rating));
std::cout << "There are now " << valids.size() << " answers";
if(hardmode == 'u')
Expand Down

0 comments on commit cc93634

Please sign in to comment.