34 lines
913 B
Python
34 lines
913 B
Python
import logging
|
|
import sys
|
|
|
|
def main():
|
|
# Logger setup
|
|
logger = logging.getLogger(__name__)
|
|
logger.setLevel(logging.INFO)
|
|
stream_handler = logging.StreamHandler()
|
|
logger.addHandler(stream_handler)
|
|
|
|
dial = 50
|
|
logger.debug("Dial: " + str(dial))
|
|
password = 0
|
|
with open("input.txt", "r") as input:
|
|
for line in input:
|
|
rotation = line.strip()
|
|
rotDirection = rotation[0]
|
|
rotValue = int(rotation[1:])
|
|
if(rotDirection == "R"):
|
|
logger.debug("-" + str(rotValue))
|
|
dial -= rotValue
|
|
else:
|
|
logger.debug("+" + str(rotValue))
|
|
dial += rotValue
|
|
dial = dial % 100
|
|
if(dial == 0):
|
|
password += 1
|
|
logger.debug("Dial: " + str(dial))
|
|
logger.info("Password: " + str(password))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|