Advertisement
SvenskaHugo

AoC day 21 part 1 ""efficiently"" done in python

Dec 21st, 2022
1,710
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.25 KB | None | 0 0
  1. file = open('21.txt','r').readlines()
  2.  
  3. for i,line in enumerate(file):
  4.   file[i] = line.replace(': ', ' = ')
  5.  
  6. done = False
  7. while not done:
  8.   done = True
  9.   for line in file:
  10.     try:
  11.       exec(line)
  12.     except:
  13.       done = False
  14.  
  15. print(root)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement