Created
March 9, 2022 22:42
-
-
Save splch/381fa3e38da4ad605a381e6cd3f5bd61 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/python3 | |
import math | |
import os | |
import random | |
import re | |
import sys | |
# | |
# Complete the 'equalStacks' function below. | |
# | |
# The function is expected to return an INTEGER. | |
# The function accepts following parameters: | |
# 1. INTEGER_ARRAY h1 | |
# 2. INTEGER_ARRAY h2 | |
# 3. INTEGER_ARRAY h3 | |
# | |
def equalStacks(h1, h2, h3): | |
while len({sum(h1), sum(h2), sum(h3)}) != 1: | |
if sum(h1) > sum(h2) and sum(h1) > sum(h3): | |
h1.pop(0) | |
elif sum(h2) > sum(h1) and sum(h2) > sum(h3): | |
h2.pop(0) | |
elif sum(h3) > sum(h2) and sum(h3) > sum(h1): | |
h3.pop(0) | |
return sum(h1) | |
if __name__ == '__main__': | |
fptr = open(os.environ['OUTPUT_PATH'], 'w') | |
first_multiple_input = input().rstrip().split() | |
n1 = int(first_multiple_input[0]) | |
n2 = int(first_multiple_input[1]) | |
n3 = int(first_multiple_input[2]) | |
h1 = list(map(int, input().rstrip().split())) | |
h2 = list(map(int, input().rstrip().split())) | |
h3 = list(map(int, input().rstrip().split())) | |
result = equalStacks(h1, h2, h3) | |
fptr.write(str(result) + '\n') | |
fptr.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment