laezee

LaEZee is a room sorting program written in python. I personally wouldn't use it and its posted here as a warning of how not to write a room sorting program.

about

LaEZee is a hotel room generator which takes a person's gender and top 3 roommates and makes an ideal room arangment list. For use by anyone but made to help schools sort throught large amounts of students when going on out-of-town trips.

the program

#!/usr/bin/python3.5
#laEZee sorting program
#by kulve and mhdrone

#this program is designed to sort hotel rooms out using a persons ideal room
#it can take an infinite amount of people, the layout for input is the person's
#name, gender, and the 3 people they want to room with starting with the first
#being the highest priority.

#Version 1.0:
#will be able to sort room simply using a pure logic comparison system
#single file system
#inputs are givin by editing the program file
#output are displayed on screen

#example names:
#Bob_Robert, John_Johnny, Jack_Lantern, Male_Example, Ryan_Rogers, Jim_Jimmy, Brad_Mint, Sam_Moss, Scott_Tott
#Carly_Care, Sue_Law, Sally_Salad, Mary_Mary, Pam_Beasley, Maggie_Mags, Beth_Smith, Amy_Sparks

Bob_Robert =        ["Male","Bob_Robert","John_Johnny","Jack_Lantern","Ryan_Rogers"]
John_Johnny =       ["Male","John_Johnny","Jack_Lantern","Bob_Robert","Male_Example"]
Jack_Lantern =      ["Male","Jack_Lantern","Jim_Jimmy","Brad_Mint", "John_Jonny"]
Male_Example =      ["Male","Male_Example","Sam_Moss","Brad_Mint","Ryan_Rogers"]
Ryan_Rogers =       ["Male","Ryan_Rogers","John_Johnny","Jim_Jimmy","Sam_Moss"]
Jim_Jimmy =         ["Male","Jim_Jimmy","Ryan_Rogers","Male_Example","Brad_Mint"]
Brad_Mint =         ["Male","Brad_Mint","Sam_Moss","Jack_Lantern","Ryan_Rogers"]
Sam_Moss =          ["Male","Sam_Moss","Brad_Mint","Scott_Tott","Bob_Robert"]
Scott_Tott =        ["Male","Scott_Tott","Male_Example","John_Johnny","Jack_Lantern"]
#Scott_Tott2 =        ["Male","Scott_Tott","Male_Example","John_Johnny","Jack_Lantern"]

Carly_Care =        ["Female","Carly_Care","Sue_Law","Sally_Salad","Mary_Mary"]
Sue_Law =           ["Female","Sue_Law","Carly_Care","Sally_Salad","Mary_Mary"]
Sally_Salad =       ["Female","Sally_Salad","Carly_Care","Sue_Law","Mary_Mary"]
Mary_Mary =         ["Female","Mary_Mary","Carly_Care","Sue_Law","Sally_Salad"]
Pam_Beasley =       ["Female","Pam_Beasley","Carly_Care","Maggie_Mags","Amy_Sparks"]
Maggie_Mags =       ["Female","Maggie_Mags","Beth_Smith","Sally_Salad","Sue_Law"]
Beth_Smith =        ["Female","Beth_Smith","Amy_Sparks","Maggie_Mags","Mary_Mary"]
Amy_Sparks =        ["Female","Amy_Sparks","Pam_Beasley","Beth_Smith","Sue_Law"]
#Carly_Care2 =        ["Female","Carly_Care","Sue_Law","Sally_Salad","Mary_Mary"]

#PACKAGES
import math as _math


#VARABLES
_Female = 'Female' #these are the words used to set gender
_Male = 'Male'
_Male_list = []
_Female_list = []
_Primary_Choice_Weight = 5
_Primary_Weight = 3
_Secondary_Weight = 2
_Third_Weight = 1


#FUNCTIONS
def _underscoreremove(): #haha its a function to remove varables that start with underscores but
    NameLoopCount = 0    #it starts with an underscore how ironic, reminds me of a lot of people
    KillCount = TotalVarsNum
    while True: #this loop removes any strings with an "_" in front of them from the list
        if NameLoopCount >= KillCount:
            break
        CurrentString = TotalVars[NameLoopCount]
        if CurrentString[0] == "_": #removes strings
            TotalVars.remove(CurrentString)
            NameLoopCount = NameLoopCount-1
            KillCount = len(TotalVars)
        NameLoopCount = NameLoopCount+1
        #print(NameLoopCount)
        
        

def _gender_sort():
    NameLoopCount = 0
    KillCount = TotalVarsNum
    #print(KillCount)
    while True:
        if NameLoopCount >= KillCount:
            break
        CurrentString = TotalVars[NameLoopCount]
        CurrentList = globals()[CurrentString]
        if CurrentList[0] == _Female: #ladies first
            _Female_list.append(CurrentString)
        if CurrentList[0] == _Male:
            _Male_list.append(CurrentString)
        #print(NameLoopCount)
        NameLoopCount = NameLoopCount+1



def _comparisonDriver2(_active_list):
    #each loop should define one roommate then pass roommate on to next loop
    #on return each loop does a comparison and reports the largest number
    _room_index = {}
    _active_list_num = len(_active_list)
    _active_list_dyn_loop = _active_list_num
    _active_list_dyn = _active_list.copy()
    _active_rooms = _math.ceil(len(_active_list)/4)
    _loop_times_zero = 0
    while True:
        if _loop_times_zero >= _active_rooms:
            break
        _roommate_one_name = None
        _roommate_two_name = None
        _roommate_three_name = None
        _roommate_four_name = None
        _loop_times_one = 0
        _comparison_value_one_one = 0
        _comparison_value_two_one = 0
        _comparison_value_one_two = 0
        _comparison_value_two_two = 0    
        _comparison_value_one_three = 0
        _comparison_value_two_three = 0
        _comparison_value_one_four = 0
        _comparison_value_two_four = 0
        while True: #Roommate one loop
            if _loop_times_one >= _active_list_dyn_loop: # gots idea = dyn loop
                break
            
            _active_list_dyn_loop = len(_active_list_dyn)
            #print(_active_list_dyn_loop)
            _active_roommate_one = _active_list_dyn[_loop_times_one]
            _roommate_one_name_check = _active_roommate_one
            _active_roommate_one = globals()[_active_roommate_one]
            
            _loop_times_two = 0
            while True: #Roommate two loop
                if _loop_times_two >= _active_list_dyn_loop:
                    break

                if _roommate_one_name_check != _active_list_dyn[_loop_times_two]:
                    _active_roommate_two = _active_list_dyn[_loop_times_two]
                    _roommate_two_name_check = _active_roommate_two
                    _active_roommate_two = globals()[_active_roommate_two]
                
                    _loop_times_three = 0
                    while True: #Roommate three loop
                        if _loop_times_three >= _active_list_dyn_loop:
                            break

                        if _roommate_one_name_check != _active_list_dyn[_loop_times_three]:
                            if _roommate_two_name_check != _active_list_dyn[_loop_times_three]:
                                _active_roommate_three = _active_list_dyn[_loop_times_three]
                                _roommate_three_name_check = _active_roommate_three
                                _active_roommate_three = globals()[_active_roommate_three]
                                
                                _loop_times_four = 0
                                while True: #Roommate four loop
                                    if _loop_times_four >= _active_list_dyn_loop:
                                        break
                                    if _roommate_one_name_check != _active_list_dyn[_loop_times_three]:
                                        if _roommate_two_name_check != _active_list_dyn[_loop_times_three]:
                                            if _roommate_three_name_check != _active_list_dyn[_loop_times_four]:
                                                _active_roommate_four = _active_list_dyn[_loop_times_four]
                                                _roommate_four_name_check = _active_roommate_four
                                                _active_roommate_four = globals()[_active_roommate_four]
                                                
                                                if _roommate_four_name_check not in (_roommate_one_name_check,_roommate_two_name_check,_roommate_three_name_check):
                                                    _comparison_value_one_four = _listComparisonSimple2(_active_roommate_one, _active_roommate_two, _active_roommate_three, _active_roommate_four)
                                                
                                                if _comparison_value_one_four > _comparison_value_two_four:
                                                    _comparison_value_two_four = _comparison_value_one_four
                                                    _comparison_value_one_three = _comparison_value_one_four
                                                    _comparison_value_one_two = _comparison_value_one_four
                                                    _comparison_value_one_one = _comparison_value_one_four
                                                    _roommate_four_name = _roommate_four_name_check
                                                    #print("4",_roommate_four_name,_comparison_value_two_four)

                                    #print("4:",_loop_times_four)
                                    _loop_times_four = _loop_times_four+1
                                    #===========================================================LOOP FOUR
                                
                                if _comparison_value_one_three > _comparison_value_two_three:
                                    _comparison_value_two_three = _comparison_value_one_three
                                    _comparison_value_one_two = _comparison_value_one_three
                                    _comparison_value_one_one = _comparison_value_one_three
                                    _roommate_three_name = _roommate_three_name_check
                                    #print("3",_roommate_three_name,_comparison_value_two_three)

                        #print("3:",_loop_times_three)
                        _loop_times_three = _loop_times_three+1
                        #===============================================================LOOP THREE
                    if _comparison_value_one_two > _comparison_value_two_two:
                        _comparison_value_two_two = _comparison_value_one_two
                        _comparison_value_one_one = _comparison_value_one_three
                        _roommate_two_name = _roommate_two_name_check
                        #print("2",_roommate_two_name,_comparison_value_two_two)

                #print("2:",_loop_times_two)
                _loop_times_two = _loop_times_two+1
                #===================================================================LOOP TWO
            
            _roommate_one_name = _roommate_one_name_check
            #print("1",_roommate_one_name,_comparison_value_two_one)
            #print("2",_roommate_two_name,_comparison_value_two_two)
            #print("3",_roommate_three_name,_comparison_value_two_three)
            #print("4",_roommate_four_name,_comparison_value_two_four)
            #print(_comparison_value_one_two)
            _comparison_value_one_two = 0
            _comparison_value_two_two = 0    
            _comparison_value_one_three = 0
            _comparison_value_two_three = 0
            _comparison_value_one_four = 0
            _comparison_value_two_four = 0
            _loop_times_one = _loop_times_one+1
            #=======================================================================LOOP ONE
        _room_index[_loop_times_zero] = {_roommate_one_name,_roommate_two_name,_roommate_three_name,_roommate_four_name}
        if _roommate_one_name in _active_list_dyn:
            _active_list_dyn.remove(_roommate_one_name)
        if _roommate_two_name in _active_list_dyn:
            _active_list_dyn.remove(_roommate_two_name)
        if _roommate_three_name in _active_list_dyn:
            _active_list_dyn.remove(_roommate_three_name)
        if _roommate_four_name in _active_list_dyn:
            _active_list_dyn.remove(_roommate_four_name)
        _loop_times_zero = _loop_times_zero+1
    if _active_list_dyn:
        print("\n* * * WARN: Failure Detected * * *\nNames were not all applied to rooms, check lists for missing people\nPeople not in room:",_active_list_dyn,"\n")
    return _room_index



def _listComparisonSimple2(_RoomMateOne,_RoomMateTwo,_RoomMateThree, _RoomMateFour):
    _Comparsion_Value = 0

    # 1 vs 234
    if _RoomMateOne[1] == _RoomMateTwo[2]: #check to see if 1 is on 2's list primary
        _Comparsion_Value = _Comparsion_Value+_Primary_Weight #add weight to value
    elif _RoomMateOne[1] == _RoomMateTwo[3]: #else check if 1 is on 2's list secondary
        _Comparsion_Value = _Comparsion_Value+_Secondary_Weight
    elif _RoomMateOne[1] == _RoomMateTwo[4]: #else check if 1 is on 2's list third
        _Comparsion_Value = _Comparsion_Value+_Third_Weight
    if _RoomMateOne[1] == _RoomMateThree[2]: #check to see if 1 is on 3's list primary
        _Comparsion_Value = _Comparsion_Value+_Primary_Weight #add weight to value
    elif _RoomMateOne[1] == _RoomMateThree[3]: #else check if 1 is on 3's list secondary
        _Comparsion_Value = _Comparsion_Value+_Secondary_Weight
    elif _RoomMateOne[1] == _RoomMateThree[4]: #else check if 1 is on 3's list third
        _Comparsion_Value = _Comparsion_Value+_Third_Weight
    if _RoomMateOne[1] == _RoomMateFour[2]: #check to see if 1 is on 4's list primary
        _Comparsion_Value = _Comparsion_Value+_Primary_Weight #add weight to value
    elif _RoomMateOne[1] == _RoomMateFour[3]: #else check if 1 is on 4's list secondary
        _Comparsion_Value = _Comparsion_Value+_Secondary_Weight
    elif _RoomMateOne[1] == _RoomMateFour[4]: #else check if 1 is on 4's list third
        _Comparsion_Value = _Comparsion_Value+_Third_Weight

    #2 vs 134
    if _RoomMateTwo[1] == _RoomMateOne[2]:
        _Comparsion_Value = _Comparsion_Value+_Primary_Weight
    elif _RoomMateTwo[1] == _RoomMateOne[3]:
        _Comparsion_Value = _Comparsion_Value+_Secondary_Weight
    elif _RoomMateTwo[1] == _RoomMateOne[4]:
        _Comparsion_Value = _Comparsion_Value+_Third_Weight
    if _RoomMateTwo[1] == _RoomMateThree[2]:
        _Comparsion_Value = _Comparsion_Value+_Primary_Weight
    elif _RoomMateTwo[1] == _RoomMateThree[3]:
        _Comparsion_Value = _Comparsion_Value+_Secondary_Weight
    elif _RoomMateTwo[1] == _RoomMateThree[4]:
        _Comparsion_Value = _Comparsion_Value+_Third_Weight
    if _RoomMateTwo[1] == _RoomMateFour[2]:
        _Comparsion_Value = _Comparsion_Value+_Primary_Weight 
    elif _RoomMateTwo[1] == _RoomMateFour[3]:
        _Comparsion_Value = _Comparsion_Value+_Secondary_Weight
    elif _RoomMateTwo[1] == _RoomMateFour[4]:
        _Comparsion_Value = _Comparsion_Value+_Third_Weight
        
    #3 vs 124
    if _RoomMateThree[1] == _RoomMateOne[2]:
        _Comparsion_Value = _Comparsion_Value+_Primary_Weight 
    elif _RoomMateThree[1] == _RoomMateOne[3]:
        _Comparsion_Value = _Comparsion_Value+_Secondary_Weight
    elif _RoomMateThree[1] == _RoomMateOne[4]:
        _Comparsion_Value = _Comparsion_Value+_Third_Weight
    if _RoomMateThree[1] == _RoomMateThree[2]:
        _Comparsion_Value = _Comparsion_Value+_Primary_Weight 
    elif _RoomMateThree[1] == _RoomMateThree[3]:
        _Comparsion_Value = _Comparsion_Value+_Secondary_Weight
    elif _RoomMateThree[1] == _RoomMateThree[4]:
        _Comparsion_Value = _Comparsion_Value+_Third_Weight
    if _RoomMateThree[1] == _RoomMateFour[2]:
        _Comparsion_Value = _Comparsion_Value+_Primary_Weight 
    elif _RoomMateThree[1] == _RoomMateFour[3]:
        _Comparsion_Value = _Comparsion_Value+_Secondary_Weight
    elif _RoomMateThree[1] == _RoomMateFour[4]:
        _Comparsion_Value = _Comparsion_Value+_Third_Weight
    
    #4 vs 123
    if _RoomMateFour[1] == _RoomMateOne[2]:
        _Comparsion_Value = _Comparsion_Value+_Primary_Weight 
    elif _RoomMateFour[1] == _RoomMateOne[3]:
        _Comparsion_Value = _Comparsion_Value+_Secondary_Weight
    elif _RoomMateFour[1] == _RoomMateOne[4]:
        _Comparsion_Value = _Comparsion_Value+_Third_Weight
    if _RoomMateFour[1] == _RoomMateTwo[2]:
        _Comparsion_Value = _Comparsion_Value+_Primary_Weight 
    elif _RoomMateFour[1] == _RoomMateTwo[3]:
        _Comparsion_Value = _Comparsion_Value+_Secondary_Weight
    elif _RoomMateFour[1] == _RoomMateTwo[4]:
        _Comparsion_Value = _Comparsion_Value+_Third_Weight
    if _RoomMateFour[1] == _RoomMateThree[2]:
        _Comparsion_Value = _Comparsion_Value+_Primary_Weight 
    elif _RoomMateFour[1] == _RoomMateThree[3]:
        _Comparsion_Value = _Comparsion_Value+_Secondary_Weight
    elif _RoomMateFour[1] == _RoomMateThree[4]:
        _Comparsion_Value = _Comparsion_Value+_Third_Weight
       
    return _Comparsion_Value



# - - - - - - - - - - - - program start - - - - - - - - - - - -

TotalVars = dir()                            #gets all the varables and sets them to TotalVars
TotalVarsNum = len(TotalVars)                #gets TotalVars' number of strings

_underscoreremove()                          #underscore function

#print(TotalVars)                             #print all the people in program


# - - - - - - - - - seperates males and females - - - - - - - - -

TotalVarsNum = len(TotalVars)                #reset the Total Var number so that it is accurate
#print(TotalVarsNum)
_gender_sort()


# - - - - - - - - - - - - - data readout - - - - - - - - - - - - - 

_Female_rooms = _math.ceil(len(_Female_list)/4)
print("Girl Rooms:",_Female_rooms)
_Male_rooms = _math.ceil(len(_Male_list)/4)
print("Boy Rooms:",_Male_rooms)
print("Girls:",*_Female_list)                  #print female list
print("Boys:",*_Male_list)                    #print male list
print("\nGirl Rooms:")
_room_index_female = _comparisonDriver2(_Female_list) #calulate female rooms
for x in _room_index_female:
    print("Room Number",x,":",*_room_index_female.get(x))
print("\nBoy Rooms:")
_room_index_male = _comparisonDriver2(_Male_list) #calulate male rooms
for x in _room_index_male:
    print("Room Number",x,":",*_room_index_male.get(x))

The plan text document can be found at https://mhdser.com/laEZee/laEZee.py in case you might want to use wget or another program to grab it.