diff options
Diffstat (limited to '2022/03')
-rw-r--r-- | 2022/03/example | 6 | ||||
-rw-r--r-- | 2022/03/input | 300 | ||||
-rw-r--r-- | 2022/03/rucksack.py | 30 |
3 files changed, 336 insertions, 0 deletions
diff --git a/2022/03/example b/2022/03/example new file mode 100644 index 0000000..f17e726 --- /dev/null +++ b/2022/03/example @@ -0,0 +1,6 @@ +vJrwpWtwJgWrhcsFMMfFFhFp +jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL +PmmdzqPrVvPwwTWBwg +wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn +ttgJtRGJQctTZtZT +CrZsJsPPZsGzwwsLwLmpwMDw diff --git a/2022/03/input b/2022/03/input new file mode 100644 index 0000000..fca63f0 --- /dev/null +++ b/2022/03/input @@ -0,0 +1,300 @@ +qFdBBvtHHfvRlfvsqldvqjPpQmnQmjnjjjTRTLGRNG +ZCWhhCsJCzSJzSbzgsmPTGNNPPNGjgLTLjgn +WJZsbJMwJcszJcScwhVltFwBFBlqddvFdHDfqq +crtTsGTtqFThGQGCrsjTwdNJwpRdnJJwffRClpSf +PWVBPVHLvHHVgvZWBzmPpnfRSJJRQnSRflRPSNSl +gmzBzDgzmZQWLDLLgVmDrqGhsscrqDMGhcqtqcFr +HsbcdVrsbVbcLfPqqQsqqtPj +mMBFzZRnmFMRBDnDFBGZDGdDqLjtdQtPtgfPfttgtqgq +BZvZZdJMBFdJhSvhbhchcHll +GNRSqRfcNTpfGCcqjfzBpDQPWBzgDpQsPWzW +rrSdnVHlbMdLdBDzgtBtBmQt +rbFwwnLFLFwlMLrFwFhMVLrGNSTfZTRhfTqjGJRRZTCNcf +QWTnQCnWNNWmTnSPQwmqDbcscbpcjPjVPbrjpq +vJhzZNlNNgdzgzJdlGzHHcHDpjsHqrvbVrbvrD +RzRdRlhLgtCwCWSLnN +SFTJFTTwTVVSJBnSTdvNNfWbZCZWNZCNNhBv +srLrcHDcsjtLcLLcrLctjlcvbDNhmWCvNhZWGZZhNvh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GccD +MvnqpLlMqCqCHMjWPPHMSHSs +NNpNNvpvBdtTrMFFMhSSwzjzchzwhzwL +VVndHqflQZZZgHSLLhjzRSmZRhcR +glGgnqbQlngnWCGJpJprtrtFrdPPGs +WqwRjzGtRzZZRRGjWBJzjwmfMTHGGssTTDsrLmmmQLMD +SNdvSdFlSNNhSPFFcPFclbQQslHmfHTDsTQMLgDTmHQQ +CNcCFvpdnWpjWwJf +PVPnVHcnRncGZqbVzHVPnnLbSMjwrzWMjSwDtWwWtwWhwDWz +pTfsQCshCllpglWWSjBMSQSrMrjM +hvpvppggCpJTvTmshgfsmZRRHqbcLPHZmPLRnmPZ +LQbhVZZmZhZjBdbGmgHqnHTmvqgnnWHr +SzCfDFFNRfsSFFMFfvprvpWzqzgqTwHTvp +CDNDFJgMDSQhjVdPJLQG +plpdLdpjjrrHJJjLrrHLFdbzzCcvzgFgcwggzPMFvvcMhM +GRtSBQNsQlMPRzRlzw +ZSTtsmBlmjLLpnpH +hglGNVSdNSghzSgCBhDFLBMBtFMMFtHtbtLL +frQZccRcqGFmFHrJ +nvfGZwvTwGTfQwvfTwfgnCSlpdnzgzslppCsCV +snTSPbQnTTnQgbmsTJsLfZwjffhpLnGRjpGfjL +dcNWcNHHlNtWHHlCtltWNFNMLZwjpGfpmrZfrFprrRGpwZfp +HmdNWCmDMVvQPDgqJs +GGFtSngQLfnSnQffgPnRgFRGRwmRJvwbBbJDwjvTbjrwhJvJ +WHClslcNNWcqNWlCZdcHsVrThBwBjbhDTDBhrvDZJTwm +NWVqqcHHNpsNcNVdVlhCMlHQQMQQzLfzQPttFGPMLSLgtF diff --git a/2022/03/rucksack.py b/2022/03/rucksack.py new file mode 100644 index 0000000..30efa92 --- /dev/null +++ b/2022/03/rucksack.py @@ -0,0 +1,30 @@ +def priority(c): + if (ord(c) >= ord("a")): + return ord(c) - ord("a") + 1 + else: + return ord(c) - ord("A") + 27 +def same(x, y): + a = set() + for x1 in x: + if x1 in y: + a.add(x1) + return list(a) +def inlists(x, y): + isin = [] + for x1 in x: + if all([x1 in y1 for y1 in y]): + isin.append(x1) + if len(isin) > 0: + return isin[0] + return None + +with open("input") as f: + compartments = [line.strip() for line in f.readlines()] +points = 0 +for i in range(0, len(compartments), 3): + group = compartments[i:i+3] + if len(group) == 3: + c = inlists(group[0], group[1:]) + if c is not None: + points += priority(c) +print(points) |