summaryrefslogtreecommitdiff
path: root/2021/9pre.cpp
diff options
context:
space:
mode:
Diffstat (limited to '2021/9pre.cpp')
-rw-r--r--2021/9pre.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/2021/9pre.cpp b/2021/9pre.cpp
new file mode 100644
index 0000000..2ef4707
--- /dev/null
+++ b/2021/9pre.cpp
@@ -0,0 +1,26 @@
+#include <iostream>
+#include <vector>
+#include <string>
+#include <cstdint>
+
+
+int main() {
+ std::vector<std::string> lines;
+ std::string line;
+ while (std::getline(std::cin, line)) {
+ for (char &c : line) c -= '0';
+ lines.emplace_back(std::move(line));
+ }
+
+ const uint64_t height = lines.size();
+ const uint64_t width = lines[0].size();
+ std::cout.put('b');
+ std::cout.put(2);
+ std::cout.put(2);
+ std::cout.write(" u8", 4);
+ std::cout.write((const char*)&height, 8);
+ std::cout.write((const char*)&width, 8);
+ for (uint64_t y = 0; y < height; y++) {
+ std::cout.write(lines[y].data(), width);
+ }
+}