Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
972 B
4
Indexable
Never
def problemTwo(l):
    # "l" in parameter is list of 20 elements
    c = 1
    biggestC=1
    start = 0
    last= l[0]
    for i in range(1,len(l)):
        if l[i]!= last:
            c=1
        else:
            c= c+1
        if c>=biggestC:
            biggestC=c
            start = i
        last = l[i]

    end = start+2
    start = start-biggestC+1

    insertEnd = False
    for i in range(len(l)):
        if i == start:
            print("(", end="")
        elif i == end-1:
            print(")", end="")
            insertEnd = True
        print(l[i], end = "")
    if not insertEnd:
        print(")")



def occupy(n):
    L = [False for i in range(n)]
    base = ["_" for i in range(n)]
    
    print("_"*n)

    counter = 0
    while counter<len(L):
        tup = longestFalse(L)
        mid = int(((tup[0]+tup[1])+1)/2)
        L[mid] = True
        base[mid] = "X"
        counter+=1
        print(base)