/ Python / 2015 / 04.py
04.py
 1  from lib import *
 2  
 3  input = read_input(2015, 4)
 4  
 5  
 6  def check(inp, cnt):
 7      return hashlib.md5(inp.encode()).hexdigest().startswith("0" * cnt)
 8  
 9  
10  def mine(cnt):
11      i = 1
12      while not check(f"{input.strip()}{i}", cnt):
13          i += 1
14      return i
15  
16  
17  print(mine(5))
18  print(mine(6))