Ad
Strings
Big Integers
Code
Diff
  • /*
    
      __uint128_t solution(char *str1, char *str2) {
        return *(uint64_t *)str1 | ( (__uint128_t) *(uint64_t *)str2 << 64 );
      }
    
      48 8b 07  mov rax, [rdi]
      48 8b 16  mov rdx, [rsi]
      c3        ret
    
    */
    
    const long solution = 54912407923297096;
    
    • __uint128_t solution(char* str1, char* str2) {
    • __uint128_t result = 0;
    • for (unsigned long i = 0; i < 7; ++i) {
    • result +=
    • (((__uint128_t) str1[i]) << (8*(i + 0))) +
    • (((__uint128_t) str2[i]) << (8*(i + 8)));
    • /*
    • __uint128_t solution(char *str1, char *str2) {
    • return *(uint64_t *)str1 | ( (__uint128_t) *(uint64_t *)str2 << 64 );
    • }
    • return result;
    • }
    • 48 8b 07 mov rax, [rdi]
    • 48 8b 16 mov rdx, [rsi]
    • c3 ret
    • */
    • const long solution = 54912407923297096;