Advent of code day 1 solution (python)


Adventofcode day 1 solution (python)

I'm learning, I will cry at the smallest critique

Main program:

# open a file called test for reading
emp = open("test.txt")
retint = 0
for x in emp: # gather each line in the text file
  f = 0 # front
  b = 0 # back
  # size of each line
  
  def back(inpstr): # read file from back and return first digit found
    y = len(inpstr) - 1
    while y >= 0:
      if x[y].isdigit():
        return x[y]
      y-=1
  
  def front(inpstr): # read file from front and return first digit found
    y = 0
    while y <= len(inpstr)-1:
      if x[y].isdigit():
        return x[y]
      y+=1
      
  retint+=int(front(x)+back(x)) # adding them 

emp.close()
print(retint)

test file from day 1 input

and that's it!
I think...