Working out solutions for Advent of Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

преди 6 години
1234567891011121314151617181920
  1. # Advent of Code 2018
  2. # December 01, puzzle 1
  3. import sys
  4. def main(args):
  5. freqlist = [0]
  6. arglist = args.split(",")
  7. arglist = [x.strip() for x in arglist]
  8. freq = 0
  9. for item in arglist:
  10. if item[0] == "+":
  11. freq += int(item[1:])
  12. elif item[0] == "-":
  13. freq -= int(item[1:])
  14. return freq
  15. if __name__ == "__main__":
  16. args = input("Paste the modulations here: ")
  17. print(main(args))