diff --git a/2022/3/3.py b/2022/3/3.py new file mode 100644 index 0000000..58dd64f --- /dev/null +++ b/2022/3/3.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python +# 2022 - Advent Of Code 3 + +#file = 'input_example.txt' +file = 'input.txt' + +prio = 0 + +with open(file, encoding="utf-8") as f: + for line in f.readlines(): + half_len = int(len(line.strip()) / 2) + str1 = line[:half_len] + str2 = line[half_len:] + common = list(set(str1).intersection(str2)) + num = ord(common[0]) + if num > 90: # lower case + prio += num - 96 + else: + prio += num - 64 + 26 + +print(prio) diff --git a/2022/3/input.txt b/2022/3/input.txt new file mode 100644 index 0000000..e12b761 --- /dev/null +++ b/2022/3/input.txt @@ -0,0 +1,300 @@ +NJvhJcQWTJWTNTFFMTqqGqfTmB +VwVzPldRZVLVRmfsvfjvqfmm +ZDPDHZHVcvDhbvnv +FHHwHBzzVCWWmmCzCPrVmgBwbLTtRFFbbbttRGRLjTcLpbbT +vhZZvdsNSdSMdNvjncppCLcLnGnj +CDZZsNZMZqdNSdlNZCqrzPHDzgrgzwVVWwmwwm +ndlndntsFJntFvccLjjLrjBShcBBfc +GpCGHzVwmmzqQWSSSfWHBhQL +mpCMGGCZVzVwGGVwmJsZnFtZnTSTJtdsvl +nCnPDGmDNmVCsVQDmGSWqvzchWSjjcWGqS +gTnBRLpfTRnrTdZgdLfRdrThvqcvWWhFFWvcFSSgjqqzjv +pfZfTMwrbLTTfsbmQtlVtHHnbs +wNdSdsbTvTZMTvTv +rrdRWdWQhFVdHWBGWQmmmnnMvCfmnhvmCmtZ +rJrVDRWpGddpbSlNSlspPP +chTNrthMMwWMTjfsmRzZszJpwm +BLnFFCngbcBnbbldDlpRjGpmsCzGsGsRGmmG +dqvnvlgbqtcPPMhH +QcLNqZbCzJDQBJJRpwzRpdnRldgnpf +GmmmvVGsHrWffrlwdCWd +CMsFVVFjCmFStGQbbLZNBbJBcTjc +LQVggbQvcLbQLHgvVLhWGGsChssrMWfzGccc +qDnRTTRqJttPfWMChJh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P +pvtDDVDVpqDfzDfngBLCwQrgCtCwFwrg +pbGjFFGGDjpbsGsmNhNFNRBBBtRhhhHv +JnczJVCvwWJvhPgghgNtNtNJ +nwVSSzdzzqSpvQSZQG +mssLLttQrsMrMzLCRmMmrrSQpvWpDNlBTBDlvNTccDQl +HdHJwJqVPwHnqJwbjJbGjnSgSTWPpNgWWpgBBgcvDWWN +ZHVwVZGwwdndqJVJqfHbGwnwrRLtLMftMvMMRrhmLMthhLmz +RgHGLbTqlZlPRZPHfvvfZttJnvfvjnzr +sVcChDVDccwNhhvjTvVzWJjnzFff +mpNcCMTCGmLqBLGH +wVJwHJHVMtMpBmDDWPQVPWDGDD +zCrlZzCblBvnCDWNGLmvGDLPNG +dqZglgbzrzbbgZqzTFSBHHFJSSSfjjSMfwhj +NMWJSjLMCnHHNMNNHWCHMbVVGBPZTrPVPBVDrBSDGTTr +zvttlFpgdtldwwvftPDPTWQdBZrsrWrGBZ +hFlFmhRFvfCbmWJWHcnj diff --git a/2022/3/input_example.txt b/2022/3/input_example.txt new file mode 100644 index 0000000..f17e726 --- /dev/null +++ b/2022/3/input_example.txt @@ -0,0 +1,6 @@ +vJrwpWtwJgWrhcsFMMfFFhFp +jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL +PmmdzqPrVvPwwTWBwg +wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn +ttgJtRGJQctTZtZT +CrZsJsPPZsGzwwsLwLmpwMDw