Untitled

Run Settings
LanguagePython
Language Version
Run Command
from random import shuffle def theMajority(A): if A[0] == A[1] or A[0] == A[2]: return [A[0]] if A[1] == A[2] or A[1] == A[0]: return [A[1]] if A[2] == A[1] or A[2] == A[0]: return [A[2]] return "something went terribly wrong" def visualize(A): if len(A) == 1: return A elif len(A) == 3: # no case for 2, just 1 and 3 # issue with this is that i really mean there's # no more than THREE ACTUAL SPECIES, excluding paceholder return theMajority(A) if len(A) % 2 == 1: A.append(-1) # some number that won't ever match grps_of_two = [[A[i], A[i+1]] for i in range(0, len(A), 2)] # left = A[:len(A)//2] # right = A[len(A)//2:] merge = [] for group in grps_of_two: if group[0] == group[1]: merge.append(group[0]) # if group[0] == "_" or group[1] == "_": # merge.append("_") # elif group[0] == group[1]: # merge.append(group[0]) # else: # merge.append("_") print("merge:", merge) return visualize(merge) X = [1]*33 + [0]*31 shuffle(X) print("shuffle:", X) ret = visualize(X) print("ret:", ret) print() print()
Editor Settings
Theme
Key bindings
Full width
Lines