Mar-27-2024, 01:03 AM
(Mar-26-2024, 05:58 PM)snippsat Wrote:Thank you very much for helping with my code, i'd really appreciate it(Mar-26-2024, 03:57 PM)MoreMoney Wrote: Thank you for your help, but i have question i just need 6 atm digit for my homework should i decrase the range for faster completion time, or they dont make any different? Thank youIt was more a example on how to speed up code a lot,i don't think you should give Numba code as a solution.
Also how to install numba properly?
Without the ability to use external libraries or multiprocessing,and given the straightforward nature of a brute-force search,
there are limitations to how much the efficiency of this algorithm can be improved with pure Python.
Can clean it up a little.
from time import time def find_pin(target_pin): for guess in range(1000000): if guess == target_pin: return True return False def valid_pin(pin): return pin.isdigit() and len(pin) == 6 pin_input = input("Enter PIN: ") start = time() if not valid_pin(pin_input): print("Entered PIN is invalid") else: target_pin = int(pin_input) if find_pin(target_pin): print(f"Found PIN in {time() - start} seconds.") else: print("PIN not found.")Numba you install withpip
.
Now my code is better
Would you like to help me with my other coding i'm stuck with?
It's about logic improvement
(Sorting Steps)
https://python-forum.io/thread-41845.html
Thank you