Notice
Recent Posts
Recent Comments
Link
«   2025/05   »
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

STUDY

제본 페이지 수 나누기 본문

py

제본 페이지 수 나누기

__main__ 2019. 1. 14. 23:01

제본 페이지 수 나누기


 열 한 개의 작은 소책자를 묶어 두 권으로 제본하려 한다. 총 페이지 수를 합하면 623 페이지이다. 어떻게 제본을 해야, 각 소책자가 중간에서 끊어지지 않고, 만들어진 두 권의 페이지수가 비슷할 수 있을까?

# I have eleven small books and their names are 'a' ~ 'k'.
# My plan is to make a TWO big books ("BB1" and "BB2") from them.
# Condition: There shoulde be NO or Minimal difference 
#            in the number of pages between the two books. 

# Hint. 
# 1. Total number of pages is 623.
# 2. You should select 6 small books.
# 3. The sum of the numbers of pages should be close to the value of `623 / 2`.

sbs = {'a':64,'b':50,'c':65,'d':40,'e':70,'f':55,'g':65,'h':51,'i':58,'j':55,'k':50}
total_pages = sum(sbs.values())
half_pages = total_pages // 2

import itertools as it
lst = list(it.combinations(sbs, 6))

sum_min = 1000
for t in lst:
    sum_pages = 0
    for sb in t:
        sum_pages += sbs[sb]
    # print (t, sum_pages, sum_min)
    if sum_pages == 311:
        print (t)



'py' 카테고리의 다른 글

Follow-The-Party, 문장 찾기  (0) 2020.06.05
남산 위안부 할머니 기림비, 빠진 이름 찾기  (0) 2020.06.05
Comments