Skip to content

Commit 4f2cad8

Browse files
committed
Note the command to generate a seed for util::make_hash
1 parent a046d5a commit 4f2cad8

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed

2023/src/day16.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ template <>
159159
struct std::hash<aoc::day16::GraphHelper_Key> {
160160
std::size_t
161161
operator()(const aoc::day16::GraphHelper_Key &key) const noexcept {
162-
// random number
162+
// random number (hexdump -n8 -e '"0x" 8/1 "%02x" "ull\n"'</dev/urandom)
163163
std::size_t seed = 0x57456df670c76ed8ull;
164164
util::make_hash(seed, key.pos.x, key.pos.y, key.dir);
165165
return seed;

2023/src/day17.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ CityMap CityMap::read(std::istream &is) {
213213
template <>
214214
struct std::hash<aoc::day17::CityMap::Key> {
215215
std::size_t operator()(const aoc::day17::CityMap::Key &key) const noexcept {
216-
// random number
216+
// random number (hexdump -n8 -e '"0x" 8/1 "%02x" "ull\n"'</dev/urandom)
217217
std::size_t seed = 0x580ac2097baf0cb7ull;
218218
util::make_hash(seed, key.pos.x, key.pos.y,
219219
key.orient == aoc::day17::Orientation::horizontal);

aoc_lib/src/lib.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ template <std::integral int_type>
495495
struct std::hash<aoc::GenericPos<int_type>> {
496496
std::size_t
497497
operator()(const aoc::GenericPos<int_type> &pos) const noexcept {
498-
// random number
498+
// random number (hexdump -n8 -e '"0x" 8/1 "%02x" "ull\n"'</dev/urandom)
499499
std::size_t seed = 0xbedb5bb0b473b6b7ull;
500500
util::make_hash(seed, pos.x, pos.y);
501501
return seed;

aoc_lib/src/util/hash.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ void murmurhash2_finalize(std::size_t &h) {
4444
h ^= h >> r;
4545
}
4646

47+
/**
48+
* Generate a seed with `hexdump -n8 -e '"0x" 8/1 "%02x" "ull\n"' </dev/urandom`
49+
*/
4750
template <util::concepts::Hashable... Ts>
4851
void make_hash(std::size_t &seed, const Ts... components) {
4952
(hash::murmurhash2_combine(seed, std::hash<Ts>{}(components)), ...);

0 commit comments

Comments
 (0)