Click here to Skip to main content
15,903,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Python
<pre>>>> import string
>>> import random
>>> def id_generator(size=6, chars=string.ascii_uppercase + string.digits):
...    return ''.join(random.choice(chars) for _ in range(size))
...
>>> id_generator()
'G5G74W'
>>> id_generator(3, "6793YUIO")
'Y3U'


What I have tried:

Non so far im stuck need your help !!
Posted
Updated 12-Nov-17 22:51pm
v2

1 solution

One way is to have a counter variable to increment count of the index of the largest number when it is found again, else reset to 1 if a new largest number is found. Partial pseudo code look like this:
INITIALIZE largestCount = 0

Inside the loop to locate the next largest number:

if numbersList[ index ] == numbersList[ largest ]:
        largestCount += 1
        # other code
elif numbersList[ index ] > numbersList[ largest ]:
        largestCount = 1
        # other code
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900