Python Forum
Joining results - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Joining results (/thread-4722.html)



Joining results - acmichelman - Sep-04-2017

I have hit an snag at the end of this schedule maker i have been creating. The way I have been able to get my results at the end of random generators is by putting "shuffle(lifeguard) shuffle(beach) shuffle(days_off)" How can I have all of these process at the same time until "lifeguard" runs out of values and then to put it into some kinda of order.
import random

beach = ['Civic','Middle', '2 Chair', 'Main', 'Malibu', 'Nassau 2', 'Nassau 5', 'Reef', 'Anchor', 'E.lido', 'Lido', 'W.Lido', 'Surfing Bay', 'Lido West', 'EAB', 'E.EAB', 'Sea Glades']
lifeguard = ['Rodriguez','Mills', 'L Fitzgerald', 'Laibach', 'Hannon', 'Ruddick', 'Pitzer', 'TFlannigann', 'Vurro', 'Harrington', 'Chase', 'Clarkson', 'Digregorio', 'Nicharkwick', 'Riobo', 'Czartoyski', 'Meringolo', 'Brady', 'Barklow', 'Treadwell', 'Flynn', 'Geodecke', 'Murphy', 'Spinella', 'Joyce', 'TFitzgerald', 'Dreidy', 'EMquade', 'Schroeder', 'Mcveigh', 'Harloff', 'Rtreadwell', 'Cdauria', 'Ochs', 'Mriordan', 'Scibelli', 'Shanley', 'Charkowick', 'Kappel', 'Shutkind', 'Tcrafa', 'BCreigh', 'JCrafa', 'Creagh', 'Fitzpatrick', 'Curry', 'KFlannigan', 'Schlicte', 'Aicher', 'Kinneally', 'CCrafa', 'Fahy', 'Mulloolly', 'Zimmerman', 'Marcote', 'Kluss', 'Wiets', 'Duaria', 'PMquade', 'Campbell', 'Ptucker', 'Henderson', 'Lupia', 'Dunn', 'Rainus', 'lark', 'Peers', 'TLark',  'Martinez', 'Scheinburg', 'Rainus', 'Techera', 'Mcglughlin', 'Carr', 'Farrel', 'Bergin', 'Demeo', 'Trebel', 'Vanella', 'Serrao', 'Brown', 'Paoli', 'Dilsner', 'Swanson', 'JBurns', 'Stapleton', 'Correa', 'Formes', 'Hurst', 'BHarrington', 'Marks', 'MByrne', 'Boccio', 'Neuwieth', 'Babel', 'Hooker', 'Orourke', 'Martinsen', 'Leone', 'Wiessburg', 'Compton', 'Mazur', 'Tucker', 'Kerr', 'Dunster', 'Hutchinson', 'TFahy', 'Giordana', 'Hughes', 'Mahony', 'Gallego', 'CoNewby', 'Vitale', 'Shineburg', 'Longo', 'Michelman', 'Henne']
days_off = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
print ('To add an lifeguards type "lifeguard.append(name of lifeguard)"')
print ('To remove an lifeguard type "lifeguard.pop(name of lifeguard)"')
print ('To get your Schedule type "XXXXXX"')


def shuffle(lifeguard):
    #randomly picks one lifeguard out from array lifeguard
    if len(lifeguard) > 0:
        random.shuffle(lifeguard)
        win = lifeguard.pop()
        print (" %s" % win)
    else:
        print ('There are no more lifeguards')

        
def shuffle(beach):
    #randomly picks one beach out from array beach
        random.shuffle(beach)
        win = beach[1]
        print (" %s" % win)



def shuffle(days_off):
    #randomly picks one beach out from array beach
        random.shuffle(days_off)
        win = days_off[1]
        print (" %s" % win)



RE: Joining results - metulburr - Sep-04-2017

and your question is?


RE: Joining results - acmichelman - Sep-04-2017

(Sep-04-2017, 10:38 PM)metulburr Wrote: and your question is?

I by a mistake posted the thread without writing anything. Fixed that


RE: Joining results - ichabod801 - Sep-04-2017

Do a while lifeguard: loop. Each time through the loop, pop a lifeguard, pick a random beach, and pick a random days off.

I don't think this will work too well as a scheduler. You could end up with no lifeguards on a given beach or a given day.


RE: Joining results - acmichelman - Sep-04-2017

(Sep-04-2017, 10:44 PM)ichabod801 Wrote: Do a while lifeguard: loop. Each time through the loop, pop a lifeguard, pick a random beach, and pick a random days off.

I don't think this will work too well as a scheduler. You could end up with no lifeguards on a given beach or a given day.

Its set up to give a lifeguard a beach and day off until there are no more lifeguards


RE: Joining results - nilamo - Sep-11-2017

Quote:
import random
 
beach = ['Civic', 'Middle', '2 Chair']
lifeguard = ['Rodriguez', 'Mills', 'L Fitzgerald']
days_off = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
 
def shuffle(days_off):
    #randomly picks one beach out from array beach
        random.shuffle(days_off)
        win = days_off[1]
        print (" %s" % win)

I've reposted your exact code, doing nothing but removing some things that don't matter.

If you define a function, and then define a function with the same name, then the original function no longer exists. So don't do that if you want to use all three of those functions. The proof is in the spam-colored pudding:
>>> def echo(a):
...   print("A: {}".format(a))
...
>>> def echo(b):
...   print("B: {}".format(b))
...
>>> def echo(c):
...   print("C: {}".format(c))
...
>>> a = "spam"
>>> echo(a)
C: spam