Completed Day3 - Very verbose code, could do with some cleanup
This commit is contained in:
parent
588b673b3f
commit
2cf4f06dd0
300
input/day03
300
input/day03
@ -0,0 +1,300 @@
|
||||
GbccTtTSGGbgrcWBGGrdgTnVQnCmNpCJlNnNPVfClcnN
|
||||
vMzvZhzhwDLVmQnClwwNQp
|
||||
FRsZFzjQFsqRzRRjDZbdtTgdHBBWGrdBdHHs
|
||||
HCLTmbCLgzNBNPSSlT
|
||||
JJGMWRJMrrdwWWGjGWMLRGLjBzNQsBzPPfflzDPBsBffDrQz
|
||||
pwJdLMjdMddWjLtwZWMMwGtHhnvnCnhvqVFFZnvbgbqVCZ
|
||||
tvMCDCSVVvDDBQFRbqWMMsWgFWgc
|
||||
BLLPTpBmfLPrHLLfLsbhRqbzRRcRHgqssR
|
||||
dfdNLmPTdNZmZdZPfpmTJLPPSvQjtSGVwQSDJSjSwDQBVCGw
|
||||
wZWTWNFqzwZbWNpSgGMVMtTHsgGs
|
||||
nlnPnPvLQjzdtsjBHBMMGSHg
|
||||
LdnrrLnhRdLLmLDRPvmdQnJDJWNqcCqZJZqfFqfcfzcq
|
||||
vPTbfWggzvGVqjsVqV
|
||||
dDcJHZcZHmMFQQMshsjcRqVChjNtqh
|
||||
dDHJDmFnrJmQFnBdMdQHJdZZlWTTPPjTLWbTzLWlTTfwjzBT
|
||||
VfmDHDfZzfLcZLLLHBFQtRJTcdjgdTgFjjtR
|
||||
WRPhMlGSshPRGgvFMtddTjjCQt
|
||||
SPhWPsbNWShsWllswGpzLmzfZwmZfqLVRrDBZB
|
||||
MtZgRgJJbbGjgDDgbjRjRbGcNdWwncBFdLBBMhFBQwnWnw
|
||||
vlpsNVsCzzfHpvTpzlSSSvppcQdfnwnWhndWndwfQLhnhcFQ
|
||||
pCsCCTHVvSzvPvHvzpPVTVHHRJJDgJZjJjqNmjZmDtJRZPNR
|
||||
GTGTbhhPjJJjBhhZsGzmfHSNsmHHgSdL
|
||||
FcFpMDFDRFfsRHSjmLjR
|
||||
CpF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HsjtHNsZ
|
||||
mmMlVllWmhmmBzzLGMWlBmpstptPRRZpPMFJSpRsFRFs
|
||||
DgjnndQcNTCCCDNcdSRSdtZPfwfwJSJJ
|
||||
gQjCQqQjHNnjDCgHNcZGZLhHzrLVLGzlrGmb
|
||||
JfwfJpBgJSMphZqtqDDG
|
||||
QcQrssrGCcMCVcMc
|
||||
RnljPRnPjWbGRbjnjbvmSzwHfHgwfJHzdLFSwBFW
|
||||
sBjbHCBCnjvsJCHBsbvwwJGfRNFFFfFGTcrVFffNHRTP
|
||||
zDqdpqMgMtgzthgDtQmzGPTVSTVrVGTFSVFFqNRF
|
||||
zDLdphmmLhMhDhQdlzgLLbjCnWswWWlrZJBswCJJZl
|
||||
FMNrQFgrVwmrpJMwMTMPflbsHPTtlSbftSjCbC
|
||||
zGnGnhnGzDqRLnZLHNHbbbHDlltNSjCl
|
||||
nzddcRzzBnRRvRRhvnQFpmpgggJVcVmMQmgN
|
||||
CCpMlhwwpJpdBlsdcjvtZDFrtmRqmDrsmv
|
||||
gzVPbjSPfSPTTTPnWVSbbvDQZZDZrFWDvFDvmvQQmZ
|
||||
LTbLTPgnTzLVPNNGnNTgVNPlGdHHCphMwHMwjMphlpjccl
|
||||
rMMrqcrmJqJqmCsTPWWGGPzPlPPrGL
|
||||
fnwqwwZwRnVlWWnzWBWlDP
|
||||
jvVHvqfpJmhtHJtH
|
||||
NLMVQjRNTJCTJtZTJc
|
||||
DlGlGHvFHGDgcFCtfhCJFtZc
|
||||
DBHGGGSDvGDPHWBGdBbSvgWDNVMjLLRnmNmjPLNPNcRQVnjj
|
||||
tsGdTJdJtNllzjGRzm
|
||||
HZvvDLLWqbBBMRMRNjVhHRmn
|
||||
vZDCvqqgBDZZjbZDrWqBvpdpFpcdpCJcPTSJJtptpP
|
@ -1,11 +1,110 @@
|
||||
#include "../aoc2022.h"
|
||||
|
||||
#define LOWEROFFSET 96
|
||||
#define UPPEROFFSET 38
|
||||
|
||||
enum ECheckType {
|
||||
eIndividual,
|
||||
eGrouped
|
||||
};
|
||||
|
||||
template <typename Output>
|
||||
struct SDay03 : public SDay<Output> {
|
||||
//Class constructor
|
||||
using SDay<Output>::SDay;
|
||||
|
||||
//Solutions to both days
|
||||
Output part1() override final { return Output(); }
|
||||
Output part2() override final { return Output(); }
|
||||
Output part1() override final {
|
||||
return readBackpacks(eIndividual);
|
||||
}
|
||||
Output part2() override final {
|
||||
return readBackpacks(eGrouped);
|
||||
}
|
||||
|
||||
int readBackpacks(ECheckType checkType) {
|
||||
this->input.clear();
|
||||
this->input.seekg(0, std::ios::beg);
|
||||
std::string line{ "" };
|
||||
int total{ 0 };
|
||||
|
||||
int counter{ 0 };
|
||||
std::string bags[3];
|
||||
|
||||
while (std::getline(this->input, line))
|
||||
{
|
||||
|
||||
if (checkType == eIndividual)
|
||||
{//Checking an individual bag
|
||||
std::string compartment1, compartment2;
|
||||
for (int i = 0; i < line.size(); i++)
|
||||
{
|
||||
if (i < (line.size() / 2))
|
||||
compartment1 += line[i];
|
||||
else
|
||||
compartment2 += line[i];
|
||||
|
||||
|
||||
}
|
||||
//Find the items that appear in both backpacks and get priority
|
||||
std::map<char, int> inCompartment1 = getMap(compartment1);
|
||||
std::map<char, int> duplicates = findDuplicates(inCompartment1, compartment2);
|
||||
total += getDuplicatePriority(duplicates);
|
||||
}
|
||||
else
|
||||
{//Checking a group of bags
|
||||
counter++;
|
||||
bags[counter % 3] = line;
|
||||
if (counter % 3 == 0)
|
||||
{
|
||||
std::map<char, int> bag1 = getMap(bags[0]);
|
||||
std::map<char, int> bag2 = findDuplicates(bag1, bags[1]);
|
||||
std::map<char, int> bag3 = findDuplicates(bag2, bags[2]);
|
||||
total += getDuplicatePriority(bag3);
|
||||
}
|
||||
}
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
//Function that take in a prefilled map and checks through a string for duplicates
|
||||
std::map<char, int> findDuplicates(std::map<char, int>& duplicates, std::string backpack) {
|
||||
std::map<char, int> newDuplicates;
|
||||
|
||||
for (int i = 0; i < backpack.size(); i++)
|
||||
{
|
||||
if (duplicates[backpack[i]] && newDuplicates.count(backpack[i]) == 0)
|
||||
{//If the item is in bothcompartments
|
||||
newDuplicates[backpack[i]] = duplicates[backpack[i]];
|
||||
}
|
||||
}
|
||||
return newDuplicates;
|
||||
}
|
||||
|
||||
//Function that takes in a string and generates a map of all of the items in it
|
||||
std::map<char, int> getMap(std::string &backpack) {
|
||||
std::map<char, int> characters;
|
||||
|
||||
for (int i = 0; i < backpack.size(); i++)
|
||||
{
|
||||
characters[backpack[i]] = getItemPriority(backpack[i]);
|
||||
}
|
||||
return characters;
|
||||
}
|
||||
|
||||
//Function that goes through a map and returns the total priority for the maps
|
||||
int getDuplicatePriority(std::map<char, int> &duplicates) {
|
||||
int total{ 0 };
|
||||
for (auto& i : duplicates)
|
||||
{//Add the sum of the duplicate items
|
||||
total += i.second;
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
//Get the proiority of an item in the backpack
|
||||
int getItemPriority(char item) {
|
||||
if (islower(item))
|
||||
return item - LOWEROFFSET;
|
||||
return item - UPPEROFFSET;
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user