Solved: 36 - Digit Separators

This commit is contained in:
David Gil de Gómez Pérez
2026-08-18 10:07:24 +03:00
parent a72d03277e
commit d05a9f44fa
+8 -3
View File
@@ -4,17 +4,22 @@ namespace cpp14 {
auto million() -> int { auto million() -> int {
// TODO: Return 1'000'000 using digit separators // TODO: Return 1'000'000 using digit separators
return 0; return 1'000'000;
} }
auto mask() -> std::uint32_t { auto mask() -> std::uint32_t {
// TODO: Return 0xFF00'00FF // TODO: Return 0xFF00'00FF
return 0; return 0xFF00'00FF;
} }
auto bits_set() -> int { auto bits_set() -> int {
// TODO: Return population count of mask() // TODO: Return population count of mask()
return 0; const auto m = mask();
auto count = 0;
for (auto i = 0; i < 32; i++) {
if (m & (1 << i)) ++count;
}
return count;
} }
} // namespace cpp14 } // namespace cpp14