Created
June 4, 2017 10:19
-
-
Save restart916/aaab7d208ab739c1f37cf4354a9880cb to your computer and use it in GitHub Desktop.
backBaekjoon_online_judge_2309
This file contains 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
import sys | |
from random import shuffle | |
inputs = [] | |
a = sys.stdin.readlines() | |
for i in range(len(a)): | |
b = int(str(a[i]).replace("\n", "")) | |
inputs.append(b) | |
inputs.sort() | |
# solution 2 : random | |
# while True: | |
# shuffle(inputs) | |
# resultHeights = inputs[0:7] | |
# if (sum(resultHeights) == 100): | |
# resultHeights.sort() | |
# for val in resultHeights: | |
# print(val) | |
# sys.exit() | |
# solution 1 : bf | |
def test (inputValues, sumHeight, resultHeights) : | |
height = inputValues[0] | |
resultHeights.append(height) | |
sumHeight += height; | |
inputValues.pop(0); | |
if len(resultHeights) == 7: | |
if sumHeight == 100: | |
for val in resultHeights: | |
print(val) | |
sys.exit() | |
pass | |
if len(inputValues) == 0: | |
pass | |
index = 0 | |
for value in inputValues : | |
nextArray = inputValues[index:]; | |
test(nextArray, sumHeight, resultHeights[:]) | |
index += 1 | |
resultArray = [] | |
sum = 0 | |
test(inputs, sum, resultArray) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment