It's Day 4 and I'm FINALLY doing one of these the minute it releases. I'm excited!
It looks like it's some weird scratchcard thing. I'm pretty sure this isn't how scratchards work... but... elves are strange in these stories. This seems pretty simple, pattern matching a bit! It might be faster to convert the strings to numbers, but honestly no math is being done on the actual numbers so it doesn't really matter. For each set, count up the matches, and the answer is 2^n-1
, where n is the number of matches.
int wins = 0;
for (string gameNum : gameNums)
{
if (find(winningNums.begin(), winningNums.end(), gameNum) != winningNums.end())
{
wins++;
}
}
Of course the elf didn't know how to play the scratch cards. They just scratched the fun little bits, and made up their own rules! But even stranger, winning with a scratch card just kinda.... gives you more scratch cards? This is going to have a strangely high number of reprints.... extremely strange. So the end goal is just getting a large amount of scratch cards.
I don't blame them though - "Number go up" is appealing.
The only thing that really needs to be added to the code is something to keep track of the number of scratchcards. Starting with 1, add N to the next W cards, where N is the number of the current scratchcard, and W is the number of wins.
map<int, int> cardCounts;
cardCounts[cardNum]++;
for (int i = 1; i <= wins; i++)
{
cardCounts[cardNum+i] += cardCounts[cardNum];
}
Oddly enough, tonight's puzzle was the easiest for me so far.
Also, I got syntax highlighting working! It will only work if javascript is enabled. If not, then you'll only see white text. So it's good!