Working out solutions for Advent of Code
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

il y a 5 ans
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))