def highest_product(list_of_ints):
	""" Get highest product using 3 integers in list of integers
		Arguments: list_of_ints [List] list of 3 or more integers,
				       can include zero, negative & positive integers

		Returns: [Integer] Highest product from 3 integers in list
		                   Product can be zero, positive or negative
	"""
	# Initialize lists of highest positive integers, # max len 3
	#				      lowest  positive integers  # max len 2
	# 				      highest negative integers, # max len 2
	#                     lowest  negative integers  # max len 3
	#                	  Boolean for zero exists in list
	highest_pos = []
	highest_neg = []
	lowest_neg = []
	lowest_pos = []
	zero_int_exists = False

	# Loop thru input list of integers:
	# 	Build lists initialized above, and set zero_int_exists

	for i in range(len(list_of_ints)):
		# Process zero
		if list_of_ints[i] == 0:               
			zero_int_exists = True

		# Process positive integer
		elif list_of_ints[i] > 0:
			if len(highest_pos) < 3:
				highest_pos.append(list_of_ints[i])
			elif list_of_ints[i] > min(highest_pos):
				highest_pos.remove(min(highest_pos))
				highest_pos.append(list_of_ints[i])

			if len(lowest_pos) < 2:
				lowest_pos.append(list_of_ints[i])
			elif list_of_ints[i] < max(lowest_pos):
				lowest_pos.remove(max(lowest_pos))
				lowest_pos.append(list_of_ints[i])
		# Process negative integer
		else:
			if len(lowest_neg) < 2:
				lowest_neg.append(list_of_ints[i])
			else:
				if list_of_ints[i] < max(lowest_neg):
					lowest_neg.remove(max(lowest_neg))
					lowest_neg.append(list_of_ints[i])

			if len(highest_neg) < 3:
				highest_neg.append(list_of_ints[i])
			else:
				if list_of_ints[i] > min(highest_neg):
					highest_neg.remove(min(highest_neg))
					highest_neg.append(list_of_ints[i]) 

	# Sort lists
	highest_pos.sort()
	lowest_pos.sort()
	lowest_neg.sort()
	highest_neg.sort()

	# Print input list, sub-lists
	print("\n", list_of_ints)
	print("zero_int_exists, highest/lowest pos, highest/lowest neg: ", 
		"\n", zero_int_exists, highest_pos, lowest_pos, highest_neg, lowest_neg)

	# Build high product candidates list
	possible_high_prods = []

	# Add positive products to high product candidates list
	if len(highest_pos) == 3:
		possible_high_prods.append(highest_pos[0] * highest_pos[1] * highest_pos[2])

	if len(lowest_neg) == 2 and len(highest_pos) >= 1:
		possible_high_prods.append(lowest_neg[0] * lowest_neg[1] * highest_pos[-1])

	# If no high product candidates, append zero and negative products to high product candidates
	if len(possible_high_prods) == 0:
		if zero_int_exists:
			possible_high_prods.append(0)
		else:
			if len(lowest_pos) == 0:
				possible_high_prods.append(highest_neg[0] * highest_neg[1] * highest_neg[2])
			else:
				possible_high_prods.append(lowest_pos[0] * lowest_pos[1] * lowest_neg[-1])
	
	print(possible_high_prods)
	return max(possible_high_prods)

############ Tests
# Positive high product from (neg * neg * pos), zero in input list
# 2 possible positive candidates (-10 * -10 * 15 = 1500), (8 * 8 * 15 = 960) 
ints = [4, 7, 2, 8, -10, 8, 15, 0, -2, -10, -1, -3, -5] 
print("Expect 1500: Got", highest_product(ints))

# Positive high product from (pos * pos * pos), zero in input list
# 2 possible positive candidates (-10 * -10 * 15 = 1500), (8 * 15 * 15 = 1800) 
ints = [4, 7, 2, 8, -10, 15, 15, 0, -2, -10, -1, -3, -5] 
print("Expect 1800: Got", highest_product(ints))

# Positive high product from (neg * neg * pos), zero in input list
# 1 possible positive candidate (4 * -2 * -5)
ints = [-2, -5, 0, 4]
print("Expect 40: Got", highest_product(ints))

# Positive high product from (neg * neg * pos), zero not in input list
# 1 possible positive candidate (4 * -2 * -5)
ints = [-2, -5, 4, 3]
print("Expect 40: Got", highest_product(ints))

# Positive high product from (pos * pos * pos), zero not in input list
# 1 possible positive candidate (3 * 4 * 10)
ints = [-6, 4, 3, 10]
print("Expect 120: Got", highest_product(ints))

# No positive products, mixed positive and negative integers, zero in list
ints = [-2, 0, 4, 3]
print("Expect zero: Got", highest_product(ints))

# Input list all negative numbers
# 1 possible candidate (-2 * -3 * -6)
ints = [-2, -5, -3, -6]
print("Expect -30: Got", highest_product(ints))

# No positive products, mixed positive and negative integers, zero not in list
# 1 possible candidate (-2 * 1 * 3)
ints = [-2, 1, 3]
print("Expect -6: Got", highest_product(ints))
d515d8f681744dae26ec3aaf2764b27795d00639
<mask token>

def highest_product(list_of_ints):
    """ Get highest product using 3 integers in list of integers
		Arguments: list_of_ints [List] list of 3 or more integers,
				       can include zero, negative & positive integers

		Returns: [Integer] Highest product from 3 integers in list
		                   Product can be zero, positive or negative
	"""
    highest_pos = []
    highest_neg = []
    lowest_neg = []
    lowest_pos = []
    zero_int_exists = False
    for i in range(len(list_of_ints)):
        if list_of_ints[i] == 0:
            zero_int_exists = True
        elif list_of_ints[i] > 0:
            if len(highest_pos) < 3:
                highest_pos.append(list_of_ints[i])
            elif list_of_ints[i] > min(highest_pos):
                highest_pos.remove(min(highest_pos))
                highest_pos.append(list_of_ints[i])
            if len(lowest_pos) < 2:
                lowest_pos.append(list_of_ints[i])
            elif list_of_ints[i] < max(lowest_pos):
                lowest_pos.remove(max(lowest_pos))
                lowest_pos.append(list_of_ints[i])
        else:
            if len(lowest_neg) < 2:
                lowest_neg.append(list_of_ints[i])
            elif list_of_ints[i] < max(lowest_neg):
                lowest_neg.remove(max(lowest_neg))
                lowest_neg.append(list_of_ints[i])
            if len(highest_neg) < 3:
                highest_neg.append(list_of_ints[i])
            elif list_of_ints[i] > min(highest_neg):
                highest_neg.remove(min(highest_neg))
                highest_neg.append(list_of_ints[i])
    highest_pos.sort()
    lowest_pos.sort()
    lowest_neg.sort()
    highest_neg.sort()
    print('\n', list_of_ints)
    print('zero_int_exists, highest/lowest pos, highest/lowest neg: ', '\n',
        zero_int_exists, highest_pos, lowest_pos, highest_neg, lowest_neg)
    possible_high_prods = []
    if len(highest_pos) == 3:
        possible_high_prods.append(highest_pos[0] * highest_pos[1] *
            highest_pos[2])
    if len(lowest_neg) == 2 and len(highest_pos) >= 1:
        possible_high_prods.append(lowest_neg[0] * lowest_neg[1] *
            highest_pos[-1])
    if len(possible_high_prods) == 0:
        if zero_int_exists:
            possible_high_prods.append(0)
        elif len(lowest_pos) == 0:
            possible_high_prods.append(highest_neg[0] * highest_neg[1] *
                highest_neg[2])
        else:
            possible_high_prods.append(lowest_pos[0] * lowest_pos[1] *
                lowest_neg[-1])
    print(possible_high_prods)
    return max(possible_high_prods)


<mask token>

def highest_product(list_of_ints):
    """ Get highest product using 3 integers in list of integers
		Arguments: list_of_ints [List] list of 3 or more integers,
				       can include zero, negative & positive integers

		Returns: [Integer] Highest product from 3 integers in list
		                   Product can be zero, positive or negative
	"""
    highest_pos = []
    highest_neg = []
    lowest_neg = []
    lowest_pos = []
    zero_int_exists = False
    for i in range(len(list_of_ints)):
        if list_of_ints[i] == 0:
            zero_int_exists = True
        elif list_of_ints[i] > 0:
            if len(highest_pos) < 3:
                highest_pos.append(list_of_ints[i])
            elif list_of_ints[i] > min(highest_pos):
                highest_pos.remove(min(highest_pos))
                highest_pos.append(list_of_ints[i])
            if len(lowest_pos) < 2:
                lowest_pos.append(list_of_ints[i])
            elif list_of_ints[i] < max(lowest_pos):
                lowest_pos.remove(max(lowest_pos))
                lowest_pos.append(list_of_ints[i])
        else:
            if len(lowest_neg) < 2:
                lowest_neg.append(list_of_ints[i])
            elif list_of_ints[i] < max(lowest_neg):
                lowest_neg.remove(max(lowest_neg))
                lowest_neg.append(list_of_ints[i])
            if len(highest_neg) < 3:
                highest_neg.append(list_of_ints[i])
            elif list_of_ints[i] > min(highest_neg):
                highest_neg.remove(min(highest_neg))
                highest_neg.append(list_of_ints[i])
    highest_pos.sort()
    lowest_pos.sort()
    lowest_neg.sort()
    highest_neg.sort()
    print('\n', list_of_ints)
    print('zero_int_exists, highest/lowest pos, highest/lowest neg: ', '\n',
        zero_int_exists, highest_pos, lowest_pos, highest_neg, lowest_neg)
    possible_high_prods = []
    if len(highest_pos) == 3:
        possible_high_prods.append(highest_pos[0] * highest_pos[1] *
            highest_pos[2])
    if len(lowest_neg) == 2 and len(highest_pos) >= 1:
        possible_high_prods.append(lowest_neg[0] * lowest_neg[1] *
            highest_pos[-1])
    if len(possible_high_prods) == 0:
        if zero_int_exists:
            possible_high_prods.append(0)
        elif len(lowest_pos) == 0:
            possible_high_prods.append(highest_neg[0] * highest_neg[1] *
                highest_neg[2])
        else:
            possible_high_prods.append(lowest_pos[0] * lowest_pos[1] *
                lowest_neg[-1])
    print(possible_high_prods)
    return max(possible_high_prods)


<mask token>
print('Expect 1500: Got', highest_product(ints))
<mask token>
print('Expect 1800: Got', highest_product(ints))
<mask token>
print('Expect 40: Got', highest_product(ints))
<mask token>
print('Expect 40: Got', highest_product(ints))
<mask token>
print('Expect 120: Got', highest_product(ints))
<mask token>
print('Expect zero: Got', highest_product(ints))
<mask token>
print('Expect -30: Got', highest_product(ints))
<mask token>
print('Expect -6: Got', highest_product(ints))

def highest_product(list_of_ints):
    """ Get highest product using 3 integers in list of integers
		Arguments: list_of_ints [List] list of 3 or more integers,
				       can include zero, negative & positive integers

		Returns: [Integer] Highest product from 3 integers in list
		                   Product can be zero, positive or negative
	"""
    highest_pos = []
    highest_neg = []
    lowest_neg = []
    lowest_pos = []
    zero_int_exists = False
    for i in range(len(list_of_ints)):
        if list_of_ints[i] == 0:
            zero_int_exists = True
        elif list_of_ints[i] > 0:
            if len(highest_pos) < 3:
                highest_pos.append(list_of_ints[i])
            elif list_of_ints[i] > min(highest_pos):
                highest_pos.remove(min(highest_pos))
                highest_pos.append(list_of_ints[i])
            if len(lowest_pos) < 2:
                lowest_pos.append(list_of_ints[i])
            elif list_of_ints[i] < max(lowest_pos):
                lowest_pos.remove(max(lowest_pos))
                lowest_pos.append(list_of_ints[i])
        else:
            if len(lowest_neg) < 2:
                lowest_neg.append(list_of_ints[i])
            elif list_of_ints[i] < max(lowest_neg):
                lowest_neg.remove(max(lowest_neg))
                lowest_neg.append(list_of_ints[i])
            if len(highest_neg) < 3:
                highest_neg.append(list_of_ints[i])
            elif list_of_ints[i] > min(highest_neg):
                highest_neg.remove(min(highest_neg))
                highest_neg.append(list_of_ints[i])
    highest_pos.sort()
    lowest_pos.sort()
    lowest_neg.sort()
    highest_neg.sort()
    print('\n', list_of_ints)
    print('zero_int_exists, highest/lowest pos, highest/lowest neg: ', '\n',
        zero_int_exists, highest_pos, lowest_pos, highest_neg, lowest_neg)
    possible_high_prods = []
    if len(highest_pos) == 3:
        possible_high_prods.append(highest_pos[0] * highest_pos[1] *
            highest_pos[2])
    if len(lowest_neg) == 2 and len(highest_pos) >= 1:
        possible_high_prods.append(lowest_neg[0] * lowest_neg[1] *
            highest_pos[-1])
    if len(possible_high_prods) == 0:
        if zero_int_exists:
            possible_high_prods.append(0)
        elif len(lowest_pos) == 0:
            possible_high_prods.append(highest_neg[0] * highest_neg[1] *
                highest_neg[2])
        else:
            possible_high_prods.append(lowest_pos[0] * lowest_pos[1] *
                lowest_neg[-1])
    print(possible_high_prods)
    return max(possible_high_prods)


ints = [4, 7, 2, 8, -10, 8, 15, 0, -2, -10, -1, -3, -5]
print('Expect 1500: Got', highest_product(ints))
ints = [4, 7, 2, 8, -10, 15, 15, 0, -2, -10, -1, -3, -5]
print('Expect 1800: Got', highest_product(ints))
ints = [-2, -5, 0, 4]
print('Expect 40: Got', highest_product(ints))
ints = [-2, -5, 4, 3]
print('Expect 40: Got', highest_product(ints))
ints = [-6, 4, 3, 10]
print('Expect 120: Got', highest_product(ints))
ints = [-2, 0, 4, 3]
print('Expect zero: Got', highest_product(ints))
ints = [-2, -5, -3, -6]
print('Expect -30: Got', highest_product(ints))
ints = [-2, 1, 3]
print('Expect -6: Got', highest_product(ints))

def highest_product(list_of_ints):
	""" Get highest product using 3 integers in list of integers
		Arguments: list_of_ints [List] list of 3 or more integers,
				       can include zero, negative & positive integers

		Returns: [Integer] Highest product from 3 integers in list
		                   Product can be zero, positive or negative
	"""
	# Initialize lists of highest positive integers, # max len 3
	#				      lowest  positive integers  # max len 2
	# 				      highest negative integers, # max len 2
	#                     lowest  negative integers  # max len 3
	#                	  Boolean for zero exists in list
	highest_pos = []
	highest_neg = []
	lowest_neg = []
	lowest_pos = []
	zero_int_exists = False

	# Loop thru input list of integers:
	# 	Build lists initialized above, and set zero_int_exists

	for i in range(len(list_of_ints)):
		# Process zero
		if list_of_ints[i] == 0:               
			zero_int_exists = True

		# Process positive integer
		elif list_of_ints[i] > 0:
			if len(highest_pos) < 3:
				highest_pos.append(list_of_ints[i])
			elif list_of_ints[i] > min(highest_pos):
				highest_pos.remove(min(highest_pos))
				highest_pos.append(list_of_ints[i])

			if len(lowest_pos) < 2:
				lowest_pos.append(list_of_ints[i])
			elif list_of_ints[i] < max(lowest_pos):
				lowest_pos.remove(max(lowest_pos))
				lowest_pos.append(list_of_ints[i])
		# Process negative integer
		else:
			if len(lowest_neg) < 2:
				lowest_neg.append(list_of_ints[i])
			else:
				if list_of_ints[i] < max(lowest_neg):
					lowest_neg.remove(max(lowest_neg))
					lowest_neg.append(list_of_ints[i])

			if len(highest_neg) < 3:
				highest_neg.append(list_of_ints[i])
			else:
				if list_of_ints[i] > min(highest_neg):
					highest_neg.remove(min(highest_neg))
					highest_neg.append(list_of_ints[i]) 

	# Sort lists
	highest_pos.sort()
	lowest_pos.sort()
	lowest_neg.sort()
	highest_neg.sort()

	# Print input list, sub-lists
	print("\n", list_of_ints)
	print("zero_int_exists, highest/lowest pos, highest/lowest neg: ", 
		"\n", zero_int_exists, highest_pos, lowest_pos, highest_neg, lowest_neg)

	# Build high product candidates list
	possible_high_prods = []

	# Add positive products to high product candidates list
	if len(highest_pos) == 3:
		possible_high_prods.append(highest_pos[0] * highest_pos[1] * highest_pos[2])

	if len(lowest_neg) == 2 and len(highest_pos) >= 1:
		possible_high_prods.append(lowest_neg[0] * lowest_neg[1] * highest_pos[-1])

	# If no high product candidates, append zero and negative products to high product candidates
	if len(possible_high_prods) == 0:
		if zero_int_exists:
			possible_high_prods.append(0)
		else:
			if len(lowest_pos) == 0:
				possible_high_prods.append(highest_neg[0] * highest_neg[1] * highest_neg[2])
			else:
				possible_high_prods.append(lowest_pos[0] * lowest_pos[1] * lowest_neg[-1])
	
	print(possible_high_prods)
	return max(possible_high_prods)

############ Tests
# Positive high product from (neg * neg * pos), zero in input list
# 2 possible positive candidates (-10 * -10 * 15 = 1500), (8 * 8 * 15 = 960) 
ints = [4, 7, 2, 8, -10, 8, 15, 0, -2, -10, -1, -3, -5] 
print("Expect 1500: Got", highest_product(ints))

# Positive high product from (pos * pos * pos), zero in input list
# 2 possible positive candidates (-10 * -10 * 15 = 1500), (8 * 15 * 15 = 1800) 
ints = [4, 7, 2, 8, -10, 15, 15, 0, -2, -10, -1, -3, -5] 
print("Expect 1800: Got", highest_product(ints))

# Positive high product from (neg * neg * pos), zero in input list
# 1 possible positive candidate (4 * -2 * -5)
ints = [-2, -5, 0, 4]
print("Expect 40: Got", highest_product(ints))

# Positive high product from (neg * neg * pos), zero not in input list
# 1 possible positive candidate (4 * -2 * -5)
ints = [-2, -5, 4, 3]
print("Expect 40: Got", highest_product(ints))

# Positive high product from (pos * pos * pos), zero not in input list
# 1 possible positive candidate (3 * 4 * 10)
ints = [-6, 4, 3, 10]
print("Expect 120: Got", highest_product(ints))

# No positive products, mixed positive and negative integers, zero in list
ints = [-2, 0, 4, 3]
print("Expect zero: Got", highest_product(ints))

# Input list all negative numbers
# 1 possible candidate (-2 * -3 * -6)
ints = [-2, -5, -3, -6]
print("Expect -30: Got", highest_product(ints))

# No positive products, mixed positive and negative integers, zero not in list
# 1 possible candidate (-2 * 1 * 3)
ints = [-2, 1, 3]
print("Expect -6: Got", highest_product(ints))