aboutsummaryrefslogtreecommitdiff
path: root/src/2015/day4/aoc.cpp
diff options
context:
space:
mode:
authorkaiwu <kaiwu2004@gmail.com>2022-03-15 18:14:07 +0800
committerkaiwu <kaiwu2004@gmail.com>2022-03-15 18:14:07 +0800
commit035a612de50f7d36fdbef0d1aee3b31f5fef4596 (patch)
tree89c0ecdb3c2e6eb5fb71582c2e8a31628d26818b /src/2015/day4/aoc.cpp
parent39fa6df7d0d95c21c7eea7ca7a424468abbf6a2c (diff)
downloadadvent-of-code-035a612de50f7d36fdbef0d1aee3b31f5fef4596.tar.gz
advent-of-code-035a612de50f7d36fdbef0d1aee3b31f5fef4596.zip
lead zeros
Diffstat (limited to 'src/2015/day4/aoc.cpp')
-rw-r--r--src/2015/day4/aoc.cpp29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/2015/day4/aoc.cpp b/src/2015/day4/aoc.cpp
index 6e47928..1bb0d4e 100644
--- a/src/2015/day4/aoc.cpp
+++ b/src/2015/day4/aoc.cpp
@@ -1,3 +1,30 @@
#include "aoc.h"
-namespace aoc2015 {}
+namespace aoc2015 {
+
+char* md5sum(char* s) {
+ static char md5[64] = {0};
+ uint8_t* x = md5String(s);
+ memset(md5, 0x0, 64);
+ for (auto i = 0; i < 16; i++) {
+ sprintf(md5 + i * 2, "%02x", x[i]);
+ }
+ return md5;
+}
+
+int lead_zeros(char* s) {
+ char* p = s;
+ int total = 0;
+ while (*p != '\0') {
+ if (*p == '0') {
+ total += 1;
+ p++;
+ }
+ else {
+ break;
+ }
+ }
+ return total;
+}
+
+} // namespace aoc2015