This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <array> | |
| #include <cstdint> | |
| #include <cstddef> | |
| #include <cmath> | |
| #include <cstdio> | |
| #include <climits> | |
| #include <vector> | |
| #include <cassert> | |
| /** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pub fn murmur3_x64_64(data: &[u8], seed: u64) -> u64 { | |
| let mut h1 = seed; | |
| let mut h2 = seed; | |
| const C1: u64 = 0x87c37b91114253d5; | |
| const C2: u64 = 0x4cf5ad432745937f; | |
| let mut i = 0; | |
| let len = data.len(); | |
| while i + 16 <= len { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class WordContext(object): | |
| def __init__(self, direction, terms): | |
| self.direction = direction | |
| self.terms = terms | |
| def __repr__(self): | |
| return f"{self.direction} - {self.terms}" | |
| def make_context_list(seq, target): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <vector> | |
| #include <cstdint> | |
| #include <cstdio> | |
| #include <cassert> | |
| #include <iostream> | |
| #include <bitset> | |
| #include <queue> | |
| #include <unordered_map> | |
| #include <string> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <bitset> | |
| int next_ge(uint64_t S, int k) { | |
| uint64_t mask = ~((1ULL << k) - 1); | |
| uint64_t candidates = S & mask; | |
| return __builtin_ctzll(candidates); | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >>> bin(0b10100 & ~0b1111) | |
| '0b10000' | |
| >>> bin(0b11000 & 0b1111) | |
| '0b1000' | |
| >>> bin(0b11000 & ~0b1111) | |
| '0b10000' | |
| >>> bin(0b01000 & ~0b1111) | |
| '0b0' | |
| >>> bin(0b11000 & ~0b1111) | |
| '0b10000' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <array> | |
| #include <vector> | |
| #include <cstring> | |
| #include <cstdlib> | |
| #include <cstdio> | |
| #include <ctime> | |
| #include <cmath> | |
| #include <algorithm> | |
| #include <iostream> | |
| #include <random> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >>> bin(8) | |
| '0b1000' | |
| >>> bin(12) | |
| '0b1100' | |
| >>> bin(16) | |
| '0b10000' | |
| >>> bin(16 + 0b100) | |
| '0b10100' | |
| >>> bin(16 + 0b100 + 0b100) | |
| '0b11000' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >>> bin(0b11011 & (~(1 << 0) | (1 << 1))) | |
| '0b11010' | |
| >>> bin(0b11011 & ~((1 << 0) | (1 << 1))) | |
| '0b11000' | |
| >>> bin(0b11011 & ~((1 << 0) | (1 << 1))) | |
| '0b11000' | |
| >>> bin(0b11011 & ~(1 << 3)) | |
| '0b10011' | |
| >>> bin(0b11011 & ~((1 << 3) | (1 << 0))) | |
| '0b10010' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fn sub_distance<const S: usize>(v1:&[u64;S], v2:&[u64;S]) -> u64 { | |
| let mut total = 0; | |
| for i in 0..S { | |
| total += v1[i] - v2[i]; | |
| } | |
| return total; | |
| } |
NewerOlder