53 lines
1.4 KiB
C++
53 lines
1.4 KiB
C++
// Solutions to the Advent Of Code 2024.
|
|
// Copyright (C) 2025 Stefan Müller
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify it under
|
|
// the terms of the GNU General Public License as published by the Free Software
|
|
// Foundation, either version 3 of the License, or (at your option) any later
|
|
// version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful, but WITHOUT
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License along with
|
|
// this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#include <aoc/MonkeyMarket.hpp>
|
|
|
|
const std::string MonkeyMarket::getPuzzleName() const
|
|
{
|
|
return "Monkey Market";
|
|
}
|
|
|
|
const int MonkeyMarket::getPuzzleDay() const
|
|
{
|
|
return 22;
|
|
}
|
|
|
|
void MonkeyMarket::processDataLine(const std::string& line)
|
|
{
|
|
uint64_t n{ std::stoull(line) };
|
|
for (int i = 0; i < getNSecretNumbers(); i++)
|
|
{
|
|
n = ((n << 6) ^ n) & getPruneValue();
|
|
n = (n >> 5) ^ n;
|
|
n = ((n << 11) ^ n) & getPruneValue();
|
|
}
|
|
part1 += n;
|
|
}
|
|
|
|
void MonkeyMarket::finish()
|
|
{
|
|
}
|
|
|
|
constexpr int MonkeyMarket::getNSecretNumbers()
|
|
{
|
|
return 2000;
|
|
}
|
|
|
|
constexpr uint64_t MonkeyMarket::getPruneValue()
|
|
{
|
|
return 16777215;
|
|
}
|