Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Toooo slow....
#1
Hi,
My code is meant to go through list 't' and check if any object from it is smaller than the first object in list 'a', if there is one, than it changes the value to '100001' which is just a sign to me that its already used, and than it goes to the next object in list 'a' and does that until it goes through the whole list 'a'. Also the values from list 't' can only be used once each. Does anyone have an idea or a clue on how to optimize or speed up this code?
for k in range(m):
    u=0
    for u in range(n): 
        if t[u]<a[k]: 
            t[u]=100001 
            a[k]=100001 
            l+=1 
            break
Larz60+ write Nov-25-2020, 06:15 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.

Fixed for you this time. Please use bbcode on future posts.
Reply


Messages In This Thread
Toooo slow.... - by Radez - Nov-25-2020, 04:13 PM
RE: Toooo slow.... - by perfringo - Nov-25-2020, 04:34 PM
RE: Toooo slow.... - by deanhystad - Nov-25-2020, 10:59 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020