Optimize function using modern C++17, std::ranges, std::array instead of std::vector.
auto get_shades(std::vector<u8> v1) { assert(v1.size() == 256); std::vector<std::vector<u8>> v2(16, std::vector<u8>(14)); for (u32 y = 0; y < 16; y++) { for (u32 x = 0; x < 14; x++) { v2[y][x] = v1[(x + 1) + y * 14]; } } std::vector<std::vector<u8>> v3(32, std::vector<u8>(7)); u32 y = 0; for (const auto&r : v2) { u32 x = 0; for (const auto &c : r) { v3[y][x++] = c; if (x > 6) { x = 0; y++; } } } return v3; } Limit your response to 300 words.
user