Wednesday, December 26, 2018

Advent of Code 2015 - Day 16: Aunt Sue

Part 1

Description

Solution

This problem can be solved without VBA and only using formulas. 

In A3:A12, are the detectable compounds. Detected values from sample are in the next column (B3:B12).I put my split input in E3:K502. My array formula in M3, for example, is

M3: {=SUMPRODUCT(IF(F3=$A$3:$A$12,1,0),IF(G3=$B$3:$B$12,1,0))}

While in P3, i just simply added up the values in M3:O3. Next, to find the right Aunt Sue, I just had to find the one whose sum is 3. Each Sue lists exactly three things, so three matches means all of them match.

Part 2

Description

Solution

For the part 2, I just needed to add these operator nest to the detected values: > next to cats and trees, < next to pomeranians and goldfish. Then, modifying my formula into:

R3: {=SUMPRODUCT(IF(F3=$A$3:$A$12,1,0),IF(NOT(ISERROR(FIND($C$3:$C$12,MID("<=>",2+SIGN(G3-$B$3:$B$12),1),1))),1,0))}

I get my expected result.

Share:

0 komentar:

Recent Posts

Categories

Blog Archive