go to start Sol W8
|home |print view |recent changes |changed November 10, 2018 |
exact
|You are 54.167.15.6 <- set your identity!

Sections: word_tally | is_palindrome |

When posting code you can leave out scaffolding like the generated code from unit tests or the #includes required. If there is already a solution that is different from yours, just add yours or discuss the difference. Caution: parallel edits might cause data loss (however, versioning happens and you can retrieve an overwritten edit).

word_tally ^

void word_tally(std::istream & in, std::ostream & out) {
	std::map<Word, int> results{};
	Word w{};
	while (in >> w) {
		results[w]++;
	}
	std::for_each(results.begin(), results.end(), [&out](auto const& pair) {
		out << pair.first << ": " << pair.second << "\n";
	});
}

is_palindrome ^

bool is_palindrome(std::string s) {
	std::string reversed{s};
	std::reverse(reversed.begin(), reversed.end());
	return s == reversed;
}


|home |print view |recent changes |changed November 10, 2018 |
exact
|You are 54.167.15.6 <- set your identity!

Sol W8
go to start