Solve the riddle...
#include <iostream>
#include <string>
#include <stdint.h>
uint64_t checksum(std::string& s) {
uint64_t result = 0;
for (auto c : s) {
result <<= 7;
result ^= c;
}
return result;
}
int main() {
std::string msg = "The answer to this question is: ";
std::cout << checksum(msg) << std::endl;
// Expected Output: 3559195706944969009
return 0;
}
Note:
auto
is a new feature since C++11.
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
No explanations have been posted yet. Check back later!