Python Forum
HELP - Calculating the complexity of my algorithm.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
HELP - Calculating the complexity of my algorithm.
#3
I didn't test it but I think your code can be simplified to something like this
def Comptage(L) :
    zeros = 0
    ones = 0

    for x in L:
        for digit in str(x):
            if digit == 0:
                zeros += 1
            elif digit == 1:
                ones += 1       

    return [zeros, ones]
Reply


Messages In This Thread
RE: HELP - Calculating the complexity of my algorithm. - by micseydel - Dec-26-2018, 10:58 PM

Forum Jump:

User Panel Messages

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