Advertisement
makispaiktis

Brute Force with 4 digits

Nov 12th, 2020 (edited)
1,771
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.74 KB | None | 0 0
  1. numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
  2. NUMBERS = [str(number) for number in numbers]
  3. letters = "abcdefghijklmnopqrstuvwxyz"
  4. LETTERS = letters.upper()
  5. possible = list()
  6. for i in range(len(NUMBERS)):
  7.     possible.append(NUMBERS[i])
  8. for i in range(len(letters)):
  9.     possible.append(letters[i])
  10. for i in range(len(LETTERS)):
  11.     possible.append(LETTERS[i])
  12. print(len(possible))
  13.  
  14. from timeit import default_timer as timer
  15. counter = 0
  16. start = timer()
  17. for a in possible:
  18.     for b in possible:
  19.         for c in possible:
  20.             for d in possible:
  21.                 counter += 1
  22.                 print(str(counter) + ":" +  str(a + b + c + d))
  23.  
  24. end = timer()
  25. elapsed = end - start
  26. print("Elapsed time: " + str(elapsed) + " seconds.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement