Advertisement
Musical_Muze

Day 4, Part 1

Dec 4th, 2019
350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.70 KB | None | 0 0
  1. #function to return true if adjacent duplicate numbers
  2. def findDupes(num1):
  3.     value = False
  4.     array1 = list(str(num1))
  5.     for x in range(0,5):
  6.         if(array1[x]==array1[x+1]):
  7.             value = True
  8.             break
  9.     return value
  10.  
  11. #function to return true if non-decreasing adjacent numbers
  12. def findDown(num1):
  13.     value = True
  14.     array1 = list(str(num1))
  15.     for x in range(0,5):
  16.         if(array1[x]>array1[x+1]):
  17.             value = False
  18.             break
  19.     return value
  20.  
  21. count = 0;
  22.  
  23. #loop to run through the range
  24. for i in range(183564,657475):
  25.     if(findDupes(i) and findDown(i)):
  26.         count += 1
  27.  
  28. print("The number of possible correct passwords is: " + str(count))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement