Skip to content

Commit

Permalink
make string checks a little more idiomatic
Browse files Browse the repository at this point in the history
  • Loading branch information
LivInTheLookingGlass committed Aug 5, 2024
1 parent a53c3a7 commit a52b29f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cplusplus/src/p0022.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ unsigned long long p0022() {
std::vector<std::string> names(5163, "");
size_t idx = 0, i = 0, pi = 0;
do {
while (fstring[i] && fstring[i] != ',')
while (i < fstring.length() && fstring[i] != ',')
i++;
const size_t len = i - pi - 2;
names[idx] = fstring.substr(pi + 1, len);
idx++;
pi = ++i;
} while (fstring[i]);
} while (i < fstring.length());
std::sort(names.begin(), names.end());
for (idx = 0; idx < name_count; idx++) {
unsigned long score = 0;
Expand Down

0 comments on commit a52b29f

Please sign in to comment.