← Back to archive

Stdle #161 · modern · 2026-11-14

What does this C++ snippet output?

A past puzzle — fully playable. 4 attempts, hints on wrong guesses.

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
int main() {
std::vector<std::string> v = {"bb", "a", "ccc"};
std::sort(v.begin(), v.end(), [](const std::string& a, const std::string& b) {
return a.size() < b.size();
});
for (auto& s : v) std::cout << s << " ";
std::cout << "\n";
}
Modern
4 attempts left

Answer & explanation