Exemplo n.º 1
0
def testSelection(n, mn, mx):
    L = random.sample(range(mn, mx), n)
    Sorts.selection(L)
    for i in range(len(L) - 2):
        if (L[i] > L[i + 1]):
            return False
    return True
Exemplo n.º 2
0
def testRadix(n, mn, mx):
    L = random.sample(range(mn, mx), n)
    Sorts.radix(L)
    for i in range(len(L) - 2):
        if (L[i] > L[i + 1]):
            return False
    return True
Exemplo n.º 3
0
def sortData(unsortedList):
    """
    This function will run the sorting algortihms, and track their data.
    Input: unsorted list
    Output: data from the sorting algorithms
    """
    # We will begin with the data from the bubble sort
    bubbleSortData = []
    bubbleSortOptData = []
    selectionSortData = []
    insertionSortData = []

    # The range of testing will begin at zero
    testRange = 0

    for i in range(len(unsortedList) + 1):
        bubbleSortCount = Sorts.bubbleSort(unsortedList[:testRange])
        bubbleSortData.append(bubbleSortCount)

        bubbleSortOptCount = Sorts.bubbleSortOpt(unsortedList[:testRange])
        bubbleSortOptData.append(bubbleSortOptCount)

        selectionSortCount = Sorts.selectionSort(unsortedList[:testRange])
        selectionSortData.append(selectionSortCount)

        insertionSortCount = Sorts.insertionSort(unsortedList[:testRange])
        insertionSortData.append(insertionSortCount)
        testRange += 1

    # Write the sort data to text file
    writeSortDataToText(bubbleSortData, bubbleSortOptData, selectionSortData,
                        insertionSortData)
def TimSort(array,n):
    for i in range(0,n,RUN):
        Sorts.insertionSort(array,i,min(i+RUN-1,n-1))
    size=RUN
    while size < n:
        for x in range(0,n,size*2):
            array[x:x+2*size]=Sorts.merge(array[x:x+size],array[x+size:x+2*size])
        size*=2
def main():
    N, s = int(sys.argv[2]), sys.argv[1]
    Arr = Crear_arreglo_random(N)
    if s == "InsertionSort":
        inicio = time.time()
        Sorts.InsertionSort(Arr, N)
        fin = time.time()
    elif s == "MergeSort":
        inicio = time.time()
        Sorts.MergeSort(Arr, 0, N - 1)
        fin = time.time()

    tiempoTranscurrido = (fin - inicio) * 1000
    print(s, N, tiempoTranscurrido)
Exemplo n.º 6
0
 def update(dt):
     triangle = pyg.media.procedural.Triangle(
         dt,
         frequency=bargraph.array[bargraph.get_cursor(1)],
         envelope=flat_env)
     triangle.play()
     if Sorts.selectionsort(bargraph, True) and reset:
         bargraph.randomize(min, max, count)
Exemplo n.º 7
0
def discovery():
    lat = float(request.args.get('lat'))
    lon = float(request.args.get('lon'))

    RestaurantsNear = InitialConditions.nearbyRestaurants(
        lon, lat)  #Finds restaurants within 1.5km
    onlineOfflineSorted = InitialConditions.onlineSort(
        RestaurantsNear)  #Sorts into online and offline
    onlineOfflineSorted = InitialConditions.offlineFilterer(
        onlineOfflineSorted[0],
        onlineOfflineSorted[1])  #Removes offline if 10 or more online

    Popularity = (Sorts.popularitySort(onlineOfflineSorted[0],
                                       onlineOfflineSorted[1])
                  )  #Popularity sorted
    Date = (Sorts.dateSort(onlineOfflineSorted[0],
                           onlineOfflineSorted[1]))  #Date sorted
    Nearest = (Sorts.nearestSort(onlineOfflineSorted[0],
                                 onlineOfflineSorted[1], lon,
                                 lat))  #Nearest sorted

    listOfSorts = [Popularity, Date, Nearest
                   ]  #List of lists of the final results to be displayed
    titles = ["Popular Restaurants", "New Restaurants", "Nearby Restaurants"]

    result = {'sections': []}  #result to be returned

    for i in range(3):

        if len(listOfSorts[i]) > 0:  #Makes sure empty lists are not added

            result['sections'].append({
                'title': titles[i],
                'restaurants': listOfSorts[i]
            })  #Appends non empty list

    return json.dumps(result)  #returns result
Exemplo n.º 8
0
def dual_pivot(T,left=0,right=None,randomize=True,threshold=16,subsort=insertion):
    if right == None:
        right = len(T) - 1
    # the lower limit of 17 is according to the paper
    if right - left < threshold:
        Sorts.insertion(T,left,right)
        return

    if randomize:
        pivot1idx = random.randrange(left,right+1)
        T[left],T[pivot1idx] = T[pivot1idx],T[left]
        pivot2idx = random.randrange(left+1,right+1)
        T[right],T[pivot2idx] = T[pivot2idx],T[right]
    #make sure left pivot is smaller
    if T[left] > T[right]:
        T[left],T[right] = T[right],T[left]
    P1, P2 = T[left], T[right]
    K = L = left + 1
    G = right - 1
    while K <= G:
        if T[K] < P1:
            T[L],T[K] = T[K],T[L]
            L += 1
            K += 1
        elif T[K] > P2:
            T[K],T[G] = T[G],T[K]
            # we haven't examined the value that was at T[G]
            # K is not advanced, so we will check it next
            G -= 1
        else:
            K += 1
    #swap pivots into final positions
    T[left],T[L-1] = T[L-1],T[left]
    T[right],T[G+1] = T[G+1],T[right]
    dual_pivot(T,left,L-2,randomize,threshold,subsort)
    dual_pivot(T,L,G,randomize,threshold,subsort)
    dual_pivot(T,G+2,right,randomize,threshold,subsort)
Exemplo n.º 9
0
    [1,2,3,4,5,6,7,8,9,10], #0:                                     10 sorted first 10 numbers
    [0,1,1,2,3,5,8,13,21,34,55], #1:                                11 sorted fib sequence
    [5,10,15,20,25,30,35,40,45,50,65,70,75,80,85,90,95,100], #2     20 sorted multiples of 5
    [3,6,9,12,15,18,21,24,27,30], #3                                10 sorted multiples of 3

    [10,9,8,7,6,5,4,3,2,1], #4                                      10 BACKsorted first 10 numbers
    [89,76,66,58,41,34,26,11,7,2], #5                               10 BACKsorted random

    [8,12,4,64,100,60,20,28,40,16], #6                              10 UNsorted multiples of 4
    [23,52,66,3,42,63,45,27,43,23,5,57,3,2,3,2], #7                 16 UNsorted random
    [90,4,23,5,2,35,23,52,3,235,23,5,42,4,5,2,32,5,57,34,25,242,435,235,23,52,4,52,3,235,235,2] #8  32 UNsorted random
]
LARGE_LIST_1 = MEDIUM_LIST[:]
LARGE_LIST_2 = MEDIUM_LIST[:]
LARGE_LIST_3 = MEDIUM_LIST[:]

ans = input('\nReady to Start Bubble Sort? (y/n)')
if ans == 'y':
    print('\n====================================BUBBLE SORT====================================\n')
    result = Sorts.bubbleSortTest(LARGE_LIST_1)
    print('FINAL SORTED LIST:\n',result)
ans = input('\nReady to Start Selection Sort? (y/n)')
if ans == 'y':
    print('\n====================================SELECTION SORT====================================\n')
    result = Sorts.selectionSortTest(LARGE_LIST_2)
    print('FINAL SORTED LIST:\n',result)
ans = input('\nReady to Start Merge Sort? (y/n)')
if ans == 'y':
    print('\n====================================MERGE SORT====================================\n')
    result = Sorts.mergeSortTest(LARGE_LIST_3)
    print('FINAL SORTED LIST:\n',result)
Exemplo n.º 10
0
 def sort(self,items):
     Sorts.dual_pivot(items)
Exemplo n.º 11
0
 def sort(self,items):
     Sorts.insertion(items)
Exemplo n.º 12
0
NearbyRestaurantsTest2 = [{'blurhash': 'UKFGw4^KM}$$x@X8N1kB10R+xEWWR8Rlt4o0', 'launch_date': '2020-02-23', 'location': [24.941244, 60.171987], 'name': 'Ketchup XL', 'online': False, 'popularity': 0.30706741877410304}, {'blurhash': 'UME,}O}zIwJXTsTGnjs*I{OHbYsRMoi~xnbI', 'launch_date': '2020-11-11', 'location': [24.9487, 60.172542], 'name': 'Relish Place', 'online': False, 'popularity': 0.6696615083382598}, {'blurhash': 'UGHdYc]|EmNdYjJW$doe57J7bcxZ8$xBbYW-', 'launch_date': '2020-03-16', 
'location': [24.931176, 60.166673], 'name': 'Heavenly Crackers House', 'online': True, 'popularity': 0.17347340947833162}, {'blurhash': 'UJG7Y{^8W-Io%yIpa#s:5hOks:sE8zxabYf~', 'launch_date': '2020-09-21', 'location': [24.94437, 60.166527], 'name': 'Awesome Olive Van', 'online': False, 'popularity': 0.5612382661825036}, {'blurhash': 'UJAw_5[.OEW;2vJ-#,a}ODJ-OEwc,VwcSgSg', 'launch_date': '2020-01-25', 'location': [24.927635, 60.160208], 'name': 'Potato Garden', 'online': False, 'popularity': 0.9385898095797295}, {'blurhash': 'UCRSO~%MR5XlqDX+eUs;RQWCkCoeh#idkqWB', 'launch_date': '2020-03-23', 'location': [24.932231, 60.159385], 'name': 'Horrific Taco Hotel', 'online': True, 'popularity': 0.3344814415485037}, {'blurhash': 'UCOAiQ%fIVxt8zRRx@V[F-Scj0WU-qoeWBof', 'launch_date': '2020-07-19', 'location': [24.949887, 60.164144], 'name': 'Ketchup Garden', 'online': True, 'popularity': 0.13868764972681744}, {'blurhash': 'UNDLy=}iEmRqT1S6nis*7uOnwKW=RDaetKk8', 'launch_date': '2020-04-15', 'location': [24.931383, 60.172675], 'name': 'Papas Burger Party', 'online': True, 'popularity': 0.8212304387029502}, {'blurhash': 'UAIcz{}vxmSuE4ItNMai6=Fns;wi-DxaX2X3', 'launch_date': '2020-01-18', 'location': [24.931684, 60.159661], 'name': 'Tomato Paste', 'online': True, 'popularity': 0.3426788599878831}, {'blurhash': 'UIGXfS,[oLS1AVJPa{sp1fo2juWV=Ko3WWS2', 'launch_date': '2020-10-15', 'location': [24.930341, 60.167461], 'name': 'Paprika Grill', 'online': True, 'popularity': 0.21829225206482272}, {'blurhash': 'UFO1ex-ANaRmd1SwwgodH|R-brt5HdsokBWX', 'launch_date': '2020-03-30', 'location': [24.945411, 60.158344], 'name': 'Heavenly Taco Palace', 'online': False, 'popularity': 0.11313881394579015}, {'blurhash': 'U9O[r*?hI_VN*8yNniVx5^NhxTknY]MmX+tx', 'launch_date': '2020-11-23', 'location': [24.935659, 60.161989], 'name': 'Chili powder', 'online': True, 'popularity': 0.7353250033621942}, {'blurhash': 'UOC~Pw#,JUo0?Rk9n%oc1PS|w]k9DZs,Szba', 'launch_date': '2020-09-06', 'location': [24.932806, 60.160777], 'name': 'Shocking', 'online': True, 'popularity': 0.06954263841889538}, {'blurhash': 'UAN=8k?LS~M:ErJFs%t0MDMWRqo@%BxSV{RX', 'launch_date': '2020-04-20', 'location': [24.938082, 60.17626], 'name': 'Sea Chain', 'online': True, 'popularity': 0.956990414084132}, {'blurhash': 'UHJ=+6?ZD+w^GstknPR+4XM}x@a#d=MytRt6', 'launch_date': '2020-06-29', 'location': [24.925349, 60.176609], 'name': 'Happy', 'online': False, 'popularity': 0.41334922328347296}, {'blurhash': 'UMD*|{}^9sn,K@XgwOj[9aNGxtbYQ;a3tQof', 'launch_date': '2020-10-10', 'location': [24.946103, 60.180464], 'name': 'Papas', 'online': True, 'popularity': 0.32967241195011165}, {'blurhash': 'UKNaZ$xnRXaQO5WEt2f7DfRpo?k8MptKV}ou', 'launch_date': '2020-03-14', 'location': [24.924752, 60.179213], 'name': 'Charming Pepper Emporium', 'online': True, 'popularity': 0.741748846018373}, {'blurhash': 'UDM+S%:dJ{TWUWTtV?v.0_n8oNX3Z|Rit9S]', 'launch_date': '2020-03-03', 'location': [24.94267, 60.159415], 'name': 'Loving Lemons', 'online': True, 'popularity': 0.18821176187284486}, {'blurhash': 'UGKp#o@uCO#SLwTIrYkBC~X7rsXRduSgb[nP', 'launch_date': '2020-11-24', 'location': [24.950464, 60.170267], 'name': 'Butter Hotel', 'online': True, 'popularity': 0.6251161053931533}, {'blurhash': 'U3QqKl}:O-m?7rJ*#pkSM9DqNuxq=vxYV^RU', 'launch_date': '2020-09-18', 'location': [24.938181, 60.162044], 'name': 'Sea', 'online': True, 'popularity': 0.4264074321140764}, {'blurhash': 'U5RVux+zIok,tUNGxZjHGjTvaMwOMHxbb^b]', 'launch_date': '2020-05-14', 'location': [24.932251, 60.1816], 'name': 'Soda Factory', 'online': False, 'popularity': 0.5942131535084464}, {'blurhash': 'UJFh9i~A9btLO7bXxHs.AAJ5s:spI1jJo@R*', 'launch_date': '2020-02-14', 'location': [24.925993, 60.171116], 'name': 'Cake Heaven', 'online': False, 'popularity': 0.698384415286917}, {'blurhash': 'UI97ru%EIvocNMa#t2oc0YIvxnR.-hocIvWF', 'launch_date': '2020-01-20', 'location': [24.938353, 60.172132], 'name': 'Chili Pepper', 'online': True, 'popularity': 0.8934866288893477}, {'blurhash': 'UKJ]2:tRJ5kV%gs;V@sW3|njn,n+U_R%ozSx', 'launch_date': '2020-04-24', 'location': [24.930713, 60.162698], 'name': 'Horrific Salami', 'online': True, 'popularity': 0.08895510522751925}, {'blurhash': 'UMD*~9$$azNK9}I@jts-12xEoKaz=wodS3R,', 'launch_date': '2020-01-06', 'location': [24.942542, 60.181301], 'name': 'Black Pepper Grill', 'online': False, 'popularity': 0.5359213679339973}, {'blurhash': 'UKGsRwwbSis92|Sis8W=6.WrW=js;cjZWra}', 'launch_date': '2020-03-20', 'location': [24.922566, 60.162293], 'name': 'Cheese Buffet', 'online': True, 'popularity': 0.34380242340441275}, {'blurhash': 'UHJZf_}jIcNfK}THnQnjElN_kSs+Q^eYtLbr', 'launch_date': '2020-07-24', 'location': [24.944815, 60.174204], 'name': 'Yucky Fish Buffet', 'online': False, 'popularity': 0.06909726749813876}, {'blurhash': 'UBP^%T-rNVeoI9M{t8ozKVX1rzWA$-ozX2kB', 'launch_date': '2020-12-07', 'location': [24.929344, 60.162536], 'name': 'Tortilla Place', 'online': True, 'popularity': 0.2389385356741786}, {'blurhash': 'UCPYm;+UJytLYlTBrgk9KrTSoLnUMDnUk$Sc', 'launch_date': '2020-08-30', 'location': [24.93467, 60.175518], 'name': 'Ultimate', 'online': False, 'popularity': 0.08156904470685529}, {'blurhash': 'U4Sw#MvXTmv.lqXem]bqTobZi}bqz#jcXfjJ', 'launch_date': '2020-08-14', 'location': [24.935493, 60.168056], 'name': 'Broccoli Garden', 'online': False, 'popularity': 0.48900879938957936}, {'blurhash': 'UFHIoI^rEURS%xx=nhV]1UJE$wkVU{R7XmtP', 'launch_date': '2020-10-16', 'location': [24.92958, 60.162341], 'name': 'Fried Cheese Burger', 'online': True, 'popularity': 0.7899445009551945}, {'blurhash': 'UCQNvu-vI3kVl+X,ixt0D_R;tJX9hkixpYbI', 'launch_date': '2020-02-21', 'location': [24.946078, 60.164069], 'name': 'Oregano Party', 'online': False, 'popularity': 0.01608086691389133}, {'blurhash': 'USCO^_~3WXERS~XRocslEfJ6oct5RCVxbHkS', 'launch_date': '2020-06-18', 'location': [24.928184, 60.174811], 'name': 'Happy Feta', 'online': True, 'popularity': 0.6475697223339456}, {'blurhash': 'UEPh{Wz}O%r^H5O;rwbbMtR#o#W-#anmSbad', 'launch_date': '2020-08-07', 'location': [24.937487, 60.17703], 'name': 'Chocolate', 'online': True, 'popularity': 0.7620805718597206}, {'blurhash': 'UDSoswyZVqm.p%cRjLaKUgZ+k.kWrFZ%a$kX', 'launch_date': '2020-11-26', 'location': [24.938908, 60.160413], 'name': 'Salt', 'online': True, 'popularity': 0.8954324472876662}, {'blurhash': 'UIE9tb,-AcxC1SNf$dWYA@S4sCS5,-slNxoJ', 'launch_date': '2020-02-17', 'location': [24.942694, 60.166713], 'name': 'Sugar Factory', 'online': False, 'popularity': 0.09127588998319809}, {'blurhash': 'U9T7pCrsevoPu8bWawfgV,bxj;kOqqkQkVf+', 'launch_date': '2020-07-19', 'location': [24.944263, 60.180763], 'name': 'Gourmet Plus', 'online': False, 'popularity': 0.7439941294724864}, {'blurhash': 'UHSFWrsTWobEpLX7jajYROWEkCkCZ_n,a$bJ', 'launch_date': '2020-08-04', 'location': [24.943179, 60.176732], 'name': 'Awesome Garlic Mafia', 'online': True, 'popularity': 0.4964753603220507}, {'blurhash': 'UFMh=D~lM|IZOjXMs:ahIcN2bXtMVgVyowtO', 'launch_date': '2020-07-23', 'location': 
[24.938778, 60.160624], 'name': 'Fake Parsley', 'online': False, 'popularity': 0.045191530459339775}, {'blurhash': 'UGB|33~3I;Ic-{%DjcRo0|Ef$%xWIMM-kQxn', 'launch_date': '2020-11-29', 'location': [24.93623, 60.169935], 'name': 'Fake Onion', 'online': True, 'popularity': 0.23036375831315775}, {'blurhash': 'UJEyvU]yA2$xPmOsrsxU1loIxUS$MTjGtKjG', 'launch_date': '2020-08-17', 'location': [24.942726, 60.17163], 'name': 'Friendly Cheddar Nation', 'online': False, 'popularity': 0.5413713376938551}, {'blurhash': 'UFD}1U_tVaoz.6P5Kboe7;KzwNrt5Pv,#=OA', 'launch_date': '2020-04-12', 'location': [24.933312, 60.169212], 'name': 'Ultimate Corn XL', 'online': False, 'popularity': 0.9715483960846673}, {'blurhash': 'UNB[ly,]JisW%2xHWUju32OTwhSeNGR*s:ju', 'launch_date': '2020-08-19', 'location': [24.938521, 60.166018], 'name': 'Fictive Spinach', 'online': True, 'popularity': 0.032796935023081085}, {'blurhash': 'UIEejN}*9|VzGob=wKV{5%S1xaS^r3RVbpxn', 'launch_date': '2020-06-06', 'location': [24.92619, 60.177111], 'name': 'Fried Spinach', 'online': True, 'popularity': 0.9395215599867948}, {'blurhash': 'UKOEbavhTJnjYrXlrYbHC%j=XRoIQ$jFoaj=', 'launch_date': '2020-01-14', 'location': [24.936201, 60.157873], 'name': 'Olive oil Planet', 'online': True, 'popularity': 0.6540829656275151}, {'blurhash': 'UGEnnv?GM|M|3D%LjFV[0,R,oyoyz;IVxtxt', 'launch_date': '2020-09-21', 'location': [24.934626, 60.165949], 'name': 'Mushroom Palace', 'online': False, 'popularity': 0.1695911542324887}, {'blurhash': 'UGIf?c^o9-V|EWovxTRpGHOGwHt1m?Vyo[xm', 'launch_date': '2020-07-19', 'location': [24.937045, 60.161703], 'name': 'Fried Pineapple', 'online': True, 'popularity': 0.7439754745659923}, {'blurhash': 'UBM[YD{FFvO*YBO$RRw6C#K}rracQ_i+x[b[', 'launch_date': '2020-02-18', 'location': [24.93755, 60.165211], 'name': 'Pineapple Plus', 'online': True, 'popularity': 0.4140474136156465}, {'blurhash': 'UDSFySu_TUk*qEcEiei|T,X|kXi%mjZ$o#kV', 'launch_date': '2020-09-25', 'location': [24.94665, 60.172647], 'name': 'Happy Corn Planet', 'online': False, 'popularity': 0.5036221275154465}, {'blurhash': 'UKB;Mk]|I^oJ1SJD$ebHESNMj[a}-4xBNeWX', 'launch_date': '2020-10-25', 'location': [24.949733, 60.166172], 'name': 'Bacon Basket', 'online': True, 'popularity': 0.9482709720911751}, {'blurhash': 'U9L~{H}NjsJ;=o$voIWY6CF4oI$dJFI_j=s%', 'launch_date': '2020-05-29', 'location': [24.937353, 60.177828], 'name': 'Real Chili', 'online': False, 'popularity': 0.7059295528321099}, {'blurhash': 'UIE.3?}T9|tMUAOrrtxV56NY$*odDIi|XfR-', 'launch_date': '2020-12-28', 'location': [24.926041, 60.175401], 'name': 'Naughty Cherry Buffet', 'online': False, 'popularity': 0.31438654332699567}, {'blurhash': 'UKD:w1{hElS_TsP4S1rv5@JC$MSzVui|ofX7', 'launch_date': '2020-11-17', 'location': [24.943237, 60.181173], 'name': 'Lovely Burger Grill', 'online': True, 'popularity': 0.03804999276898971}, {'blurhash': 'UNDVs2}5JWOFFyt2$eRoGZKPniw[VyRoS}t2', 'launch_date': '2020-05-04', 'location': [24.945715, 60.167827], 'name': 'Real Pizza Factory', 'online': True, 'popularity': 0.5045108175927286}, {'blurhash': 'UEJa-_?G9?wOAoxtr^NH7*SKwPf}r2M{kkxt', 'launch_date': '2020-02-21', 'location': [24.926597, 60.166347], 'name': 'Fresh Cheddar', 'online': True, 'popularity': 0.3576193037298722}, {'blurhash': 'UPCc|#{.NxJ~TpTEi~rwJ4O7XNs;RDi%xCk7', 'launch_date': '2020-04-04', 'location': [24.935016, 60.164915], 'name': 'Fresh Sea Party', 'online': True, 'popularity': 0.03822281103630245}, {'blurhash': 'UJJEP?}mE8R,K|TGrtahENJ8owsoQveYtMbY', 'launch_date': '2020-10-04', 'location': [24.923411, 60.172111], 'name': 'Crispy', 'online': True, 'popularity': 0.35130391441431497}, {'blurhash': 'ULFgVE}sE3bvGNORnUj=A1JCoaniMUj0tMS5', 'launch_date': '2020-09-24', 'location': [24.936465, 60.178633], 'name': 'Loving Meat Basket', 'online': True, 'popularity': 0.7400471016913404}, {'blurhash': 'UQN%6l.XV_M-V^axovocMpRFafotaPahkBoy', 'launch_date': '2020-06-23', 'location': [24.928492, 60.165993], 'name': 'Real Pepperoni Place', 'online': False, 'popularity': 0.015356838945972454}, {'blurhash': 'UKB#lk=qEmxC-}t2Rooc2^OY#+bHMSRUo]nj', 'launch_date': '2020-02-03', 'location': [24.933311, 60.160549], 'name': 'Horrific Lettuce', 'online': True, 'popularity': 0.5322843011301973}, {'blurhash': 'UQCBXU,@JQn,${xEWXWo31OTwzW-N4Ncs+sV', 'launch_date': '2020-01-12', 'location': [24.925688, 60.178389], 'name': 'Cucumber Hotel', 'online': True, 'popularity': 0.6259073873586668}, {'blurhash': 'UGAWDQ}kEQJD?GxtRkn$1RF4$z$e9HM|tRS$', 'launch_date': '2020-06-19', 'location': [24.951305, 60.175722], 'name': 'Happy Parmesan', 'online': True, 'popularity': 0.5849846458054436}, {'blurhash': 'UFT8lemKgHpAq2cPesi%b.b.f~e?rLikf7f}', 'launch_date': '2020-12-20', 'location': [24.949907, 60.161059], 'name': 'Italian Garden', 'online': True, 'popularity': 0.0847131674543133}, {'blurhash': 'UBO1xu~SIWNdUWTun6soDVMltPtMU{n5tQR,', 'launch_date': '2020-04-24', 'location': [24.942847, 60.169778], 'name': 'Fictive Olive Mafia', 'online': True, 'popularity': 0.2233905847654424}, {'blurhash': 'UHGBu9@;7ikVYeTbVyv}8JbH+ZS~MVR:pBX8', 'launch_date': '2020-08-06', 'location': [24.946196, 60.175098], 'name': 'Awesome Pizza', 'online': False, 'popularity': 0.5154888517097342}, {'blurhash': 'UCQ6y[?XIXV[YtX}nAoLHtRPtio{U.Z:pAf#', 'launch_date': '2020-07-12', 'location': [24.950317, 60.175937], 'name': 'Basil Basil', 'online': False, 'popularity': 0.9197323696645769}, {'blurhash': 'UINaxb-$I0o]Y2XkjFs,DHV{teRoVaa3ofja', 'launch_date': '2020-06-07', 'location': [24.938674, 60.168519], 'name': 'Smoky Tomato', 'online': False, 'popularity': 0.14509987938919433}, {'blurhash': 'UFBo;%|1J.J,6^FqwfwgAyJqsjbD,GwgS6Wr', 'launch_date': '2020-02-27', 'location': [24.940998, 60.180715], 'name': 'Onion Party', 'online': True, 'popularity': 0.2362352533637076}, {'blurhash': 'UCBTpy]pjuNtS2S2jtoL1tAVa|w|$Qw|a|Nt', 'launch_date': '2020-06-11', 'location': [24.933647, 60.159362], 'name': 'Pesto Palace', 'online': True, 'popularity': 0.22050050997202555}, {'blurhash': 'UGGb5p^|4@xEESt6xWWD1vS2xGkBQ;NHtixY', 'launch_date': '2020-12-24', 'location': 
[24.933944, 60.16461], 'name': 'Papas Octopus Factory', 'online': True, 'popularity': 0.3595856939421856}, {'blurhash': 'UEMbL}{2JCO=K=TBnUnlG@K~k7rrVinBxUkS', 'launch_date': '2020-03-25', 'location': [24.944127, 60.163883], 'name': 'Shrimp Nation', 'online': False, 'popularity': 0.5838466845822695}, {'blurhash': 'USL_FctRRPoftkozV@j[9pWBofaxVaRjozax', 'launch_date': '2020-03-14', 'location': [24.929032, 60.161217], 'name': 'Loving Ham', 'online': True, 'popularity': 0.18385418536189813}, {'blurhash': 'UNCY{d~TM~IpS[XMoeo49ON2xpf#aPV{a#xr', 'launch_date': '2020-09-14', 'location': [24.949398, 60.162979], 'name': 'Real Carrot Fest', 'online': True, 'popularity': 0.11785157629562806}, {'blurhash': 'UIDbdj=cNuNH%zENWBxZ1Hb]$PkCD6%1ozt6', 'launch_date': '2020-10-28', 'location': [24.922481, 60.170761], 'name': 'Tempting Lemon Van', 'online': True, 'popularity': 0.7606795592575231}, {'blurhash': 'UGEx*N~A9]VtBotR$hNH2+S1sXoyq{Iob@%1', 'launch_date': '2020-05-21', 'location': [24.923416, 60.161504], 'name': 'Fake Crust Factory', 'online': True, 'popularity': 0.197521894310212}, {'blurhash': 'UBN*,K%ORiWAadaxogof9DITt8ogxvogRiWA', 'launch_date': '2020-11-08', 'location': [24.947294, 60.170424], 'name': 'Chili Flakes', 'online': False, 'popularity': 0.112073551371331}, {'blurhash': 'UELnB2~oD*M#L6c4wjWFD6IBpFtPm{Z=jpt1', 'launch_date': '2020-09-07', 'location': [24.952036, 60.169315], 'name': 'Fried Pasta', 'online': False, 'popularity': 0.47589749120556957}, {'blurhash': 'UHJ7Cs~b98bIbcRoobxn4iRp%DRoIJWEodRo', 'launch_date': '2020-02-05', 'location': [24.923458, 60.171231], 'name': 'Tortilla Hotel', 'online': False, 'popularity': 0.2085500606669288}, {'blurhash': 'UCQcUH+eKMrwUMc6nBbYGDW;obbqmwV|otnj', 'launch_date': '2020-04-07', 'location': [24.93576, 60.181688], 'name': 'Ketchup Basket', 'online': False, 'popularity': 0.08067670139448418}, {'blurhash': 'U2Sura#SR;wMaVX9s%f*Hlobbbk9?7jFV{aO', 'launch_date': '2020-03-04', 'location': [24.937525, 60.168944], 'name': 'French Bread', 'online': False, 'popularity': 0.4706908423058939}, {'blurhash': 'UML=^6r=TJniC,X9rXX8HBniXSjZ*|X8XSjZ', 'launch_date': '2020-06-25', 'location': [24.939131, 60.169804], 'name': 'Pineapple', 'online': False, 'popularity': 0.29640961072116995}, {'blurhash': 'UJEszG@*B|s;Q5TIv%s;BMKds;w4D~enozSd', 'launch_date': '2020-05-18', 'location': [24.937382, 60.17137], 'name': 'Italian Garden', 'online': False, 'popularity': 0.4605295009804449}]

# The variable used to check second test for nearbyRestaurants

PopularityTest1 = [{'blurhash': 'UAN=8k?LS~M:ErJFs%t0MDMWRqo@%BxSV{RX', 'launch_date': '2020-04-20', 'location': [24.938082, 60.17626], 'name': 'Sea Chain', 'online': True, 'popularity': 0.956990414084132}, {'blurhash': 'UKB;Mk]|I^oJ1SJD$ebHESNMj[a}-4xBNeWX', 'launch_date': '2020-10-25', 'location': [24.949733, 60.166172], 'name': 'Bacon Basket', 'online': True, 'popularity': 0.9482709720911751}, {'blurhash': 'UIEejN}*9|VzGob=wKV{5%S1xaS^r3RVbpxn', 'launch_date': '2020-06-06', 'location': [24.92619, 60.177111], 'name': 'Fried Spinach', 'online': True, 'popularity': 0.9395215599867948}, {'blurhash': 'UDSoswyZVqm.p%cRjLaKUgZ+k.kWrFZ%a$kX', 'launch_date': '2020-11-26', 'location': [24.938908, 60.160413], 'name': 'Salt', 'online': True, 'popularity': 0.8954324472876662}, {'blurhash': 'UI97ru%EIvocNMa#t2oc0YIvxnR.-hocIvWF', 'launch_date': '2020-01-20', 'location': [24.938353, 60.172132], 'name': 'Chili Pepper', 'online': True, 'popularity': 0.8934866288893477}, {'blurhash': 'UNDLy=}iEmRqT1S6nis*7uOnwKW=RDaetKk8', 'launch_date': '2020-04-15', 'location': [24.931383, 60.172675], 'name': 'Papas Burger Party', 'online': True, 'popularity': 0.8212304387029502}, {'blurhash': 'UFHIoI^rEURS%xx=nhV]1UJE$wkVU{R7XmtP', 'launch_date': '2020-10-16', 'location': [24.92958, 60.162341], 'name': 'Fried Cheese Burger', 'online': True, 'popularity': 0.7899445009551945}, {'blurhash': 'UEPh{Wz}O%r^H5O;rwbbMtR#o#W-#anmSbad', 
'launch_date': '2020-08-07', 'location': [24.937487, 60.17703], 'name': 'Chocolate', 'online': True, 'popularity': 0.7620805718597206}, {'blurhash': 'UIDbdj=cNuNH%zENWBxZ1Hb]$PkCD6%1ozt6', 'launch_date': '2020-10-28', 'location': [24.922481, 60.170761], 'name': 'Tempting Lemon Van', 'online': True, 'popularity': 0.7606795592575231}, {'blurhash': 'UGIf?c^o9-V|EWovxTRpGHOGwHt1m?Vyo[xm', 'launch_date': '2020-07-19', 'location': [24.937045, 60.161703], 'name': 'Fried Pineapple', 'online': True, 'popularity': 0.7439754745659923}]

# The variable used to check first test for Popularity test 

RestaurantsNear = InitialConditions.nearbyRestaurants(24.941,60.1709)  
onlineOfflineSorted = InitialConditions.onlineSort(RestaurantsNear) 
onlineOfflineSorted = InitialConditions.offlineFilterer(onlineOfflineSorted[0],onlineOfflineSorted[1])
Popularity = (Sorts.popularitySort(onlineOfflineSorted[0],onlineOfflineSorted[1]))

# The popularity sort function result for Popularity test 1

PopularityTest2 = [{'blurhash': 'UKNaZ$xnRXaQO5WEt2f7DfRpo?k8MptKV}ou', 'launch_date': '2020-03-14', 'location': [24.924752, 60.179213], 'name': 'Charming Pepper Emporium', 'online': True, 'popularity': 0.741748846018373}]

# The variable used to check second test for popularity test

RestaurantsNear = InitialConditions.nearbyRestaurants(24.91,60.19)  
onlineOfflineSorted = InitialConditions.onlineSort(RestaurantsNear) 
onlineOfflineSorted = InitialConditions.offlineFilterer(onlineOfflineSorted[0],onlineOfflineSorted[1])
Popularity2 = (Sorts.popularitySort(onlineOfflineSorted[0],onlineOfflineSorted[1]))

# The popularity sort function result for popularity test 2

DateTest1 = [{'blurhash': 'UGGb5p^|4@xEESt6xWWD1vS2xGkBQ;NHtixY', 'launch_date': '2020-12-24', 'location': [24.933944, 60.16461], 'name': 'Papas Octopus Factory', 'online': True, 'popularity': 0.3595856939421856}, {'blurhash': 'UFT8lemKgHpAq2cPesi%b.b.f~e?rLikf7f}', 'launch_date': '2020-12-20', 'location': [24.949907, 60.161059], 'name': 'Italian Garden', 'online': True, 'popularity': 0.0847131674543133}, {'blurhash': 'UBP^%T-rNVeoI9M{t8ozKVX1rzWA$-ozX2kB', 'launch_date': '2020-12-07', 'location': [24.929344, 60.162536], 'name': 'Tortilla Place', 'online': True, 'popularity': 0.2389385356741786}, {'blurhash': 'UGB|33~3I;Ic-{%DjcRo0|Ef$%xWIMM-kQxn', 'launch_date': '2020-11-29', 'location': [24.93623, 60.169935], 'name': 'Fake Onion', 'online': True, 'popularity': 0.23036375831315775}, {'blurhash': 'UDSoswyZVqm.p%cRjLaKUgZ+k.kWrFZ%a$kX', 'launch_date': '2020-11-26', 'location': [24.938908, 60.160413], 'name': 'Salt', 'online': True, 'popularity': 0.8954324472876662}, {'blurhash': 'UGKp#o@uCO#SLwTIrYkBC~X7rsXRduSgb[nP', 'launch_date': '2020-11-24', 'location': [24.950464, 60.170267], 'name': 'Butter Hotel', 'online': True, 'popularity': 0.6251161053931533}, {'blurhash': 'U9O[r*?hI_VN*8yNniVx5^NhxTknY]MmX+tx', 'launch_date': '2020-11-23', 'location': [24.935659, 60.161989], 'name': 'Chili powder', 'online': True, 'popularity': 0.7353250033621942}, {'blurhash': 'UKD:w1{hElS_TsP4S1rv5@JC$MSzVui|ofX7', 'launch_date': '2020-11-17', 'location': [24.943237, 60.181173], 'name': 'Lovely Burger Grill', 'online': True, 'popularity': 0.03804999276898971}, {'blurhash': 'UIDbdj=cNuNH%zENWBxZ1Hb]$PkCD6%1ozt6', 'launch_date': '2020-10-28', 'location': [24.922481, 60.170761], 'name': 'Tempting Lemon Van', 'online': True, 'popularity': 0.7606795592575231}, {'blurhash': 'UKB;Mk]|I^oJ1SJD$ebHESNMj[a}-4xBNeWX', 'launch_date': '2020-10-25', 'location': [24.949733, 60.166172], 
Exemplo n.º 13
0
 def on_mouse_scroll(x, y, scrollx, scrolly):
     Sorts.bogosort(bargraph, True)
import Sorts
from random import randint


def ArregloAleatorio(n_elementos):
    A = []
    for i in range(0, n_elementos):
        A.append(randint(0, n_elementos))
    return A


nombre_algoritmo = sys.argv[1]
n_elementos = int(sys.argv[2])

A = ArregloAleatorio(n_elementos)

inicio = time.time()

if (nombre_algoritmo == 'InsertionSort'):
    Busquedas.InsertSort(A, 0, n_elementos)
    fin = time.time()

if (nombre_algoritmo == 'MergeSort'):
    Sorts.MergeSort(A, 0, n_elementos - 1)
    fin = time.time()

tiempoTranscurrido = (fin - inicio) * 1000

print(
    str(nombre_algoritmo) + " " + str(n_elementos) + " " + " " +
    str(tiempoTranscurrido))
Exemplo n.º 15
0
 def sort(self,items):
     Sorts.introsort(items)
Exemplo n.º 16
0
#!/usr/bin/env python
import sys
sys.path.append("lib/")
import Sorts

a = [1,3,2,5,7,11,20,2,1,44]
Sorts.dual_pivot(a)
print a
import Sorts
import sys
import time
from random import randint

inicio = time.time()
algoritmo = str(sys.argv[1])
n = int(sys.argv[2])
i = 0
A = []
while i != n:
    A.append(randint(0, 1000))
    i = i + 1
if algoritmo == "MergeSort":
    Sorts.MergeSort(A, 0, n - 1)
else:
    Sorts.InsertionSort(A, 0, n)
fin = time.time()
tiempo = (fin - inicio) * 1000
print(algoritmo, n, str(tiempo))