Advent Of Code Day 4: Security Through Obscurity


import re import string code = "aaaaa-bbb-z-y-x-123[abxyz]" sep = '[' noCheckSum = code.split(sep, 1)[0] checkSum = re.sub(r'\W+', '', code[code.index("["):]) alphabets = string.ascii_lowercase checkSumCode = "" for x in range (0, len (alphabets)): c = noCheckSum.count(alphabets[x]) if (c > 0): checkSumCode = checkSumCode + alphabets[x] checkSumCode = ''.join(sorted(checkSumCode)) if (checkSumCode == checkSum): print ("Real Room.") else: print ("Not a real room.")

Loading Please Wait...