Problem 106

A place to air possible concerns or difficulties in understanding ProjectEuler problems. This forum is not meant to publish solutions. This forum is NOT meant to discuss solution methods or giving hints how a problem can be solved.
Forum rules
As your posts will be visible to the general public you are requested to be thoughtful in not posting anything that might explicitly give away how to solve a particular problem.

This forum is NOT meant to discuss solution methods for a problem.

In particular don't post any code fragments or results.

Don't start begging others to give partial answers to problems

Don't ask for hints how to solve a problem

Don't start a new topic for a problem if there already exists one


See also the topics:
Don't post any spoilers
Comments, questions and clarifications about PE problems.
btilly
Posts: 44
Joined: Fri Sep 26, 2008 7:45 am

Re: Clarification on 106

Post by btilly »

hk wrote:What makes you think the subsets need to have equal cardinality when counting up to 25?
The fact that we're only asked about the first rule, which only applies to subsets of equal size.

Judging from that you seem to be counting "disjoint pairs of non-empty subsets". (Checks all 3 numbers.) Yup. You are. And I found the 70 of size 7.

I think I see how to do it for 12 though I probably won't code it until after my hand heals.
User avatar
daniel.is.fischer
Posts: 2400
Joined: Sun Sep 02, 2007 11:15 pm
Location: Bremen, Germany

Re: Clarification on 106

Post by daniel.is.fischer »

What happened to your hand?
Il faut respecter la montagne -- c'est pourquoi les gypaètes sont là.
btilly
Posts: 44
Joined: Fri Sep 26, 2008 7:45 am

Re: Clarification on 106

Post by btilly »

daniel.is.fischer wrote:What happened to your hand?
I was playing volleyball, two of us went for a spike receive, my fingers bent backwards and I broke the bone right under my ring finger on my right hand.

I'll be in a cast until at least Jan 8, and will be very busy after that. In the meantime I am trying to type one-handed.
Last edited by btilly on Wed Dec 17, 2008 1:15 am, edited 1 time in total.
User avatar
daniel.is.fischer
Posts: 2400
Joined: Sun Sep 02, 2007 11:15 pm
Location: Bremen, Germany

Re: Clarification on 106

Post by daniel.is.fischer »

Ouch. That hurts. Best wishes for a quick healing.
Il faut respecter la montagne -- c'est pourquoi les gypaètes sont là.
btilly
Posts: 44
Joined: Fri Sep 26, 2008 7:45 am

Re: Clarification on 106

Post by btilly »

Thanks. It will be fine, it is just a pain.
Babamots
Posts: 1
Joined: Thu May 03, 2012 3:30 am

Re: Problem 106

Post by Babamots »

I had a tough time understanding what was meant by "need to be tested." I'd appreciate it if someone would correct me if I'm wrong:

When the problem refers to subsets that "need to be tested for equality," it means pairs of subsets that COULD have equal sums without breaking prior conditions (condition ii. and strictly increasing elements) and therefore must be tested.

In particular, when n=4 and the set is {a,b,c,d} we only need to check whether S({a,d}) = S({b,c}) since:
  • Disjoint sets of unequal size have different sums (condition ii.).
    Disjoint sets of size 1 have one element each and the elements are distinct (strictly increasing elements).
    The only disjoint sets of size 2 are {a,b},{c,d} and {a,d},{b,c}. It is not possible that S({a,b}) = S({c,d}) since a<c, b<d (and consequently S({a,b}) < S({c,d}) ), so the only thing we need to test is S({a,d}) = S({b,c}).
User avatar
jaap
Posts: 588
Joined: Tue Mar 25, 2008 3:57 pm
Contact:

Re: Problem 106

Post by jaap »

Babamots wrote:I had a tough time understanding what was meant by "need to be tested." I'd appreciate it if someone would correct me if I'm wrong:
That's correct, though you did overlook disjoint sets {a,c},{b,d}, for which you can deduce that they cannot possibly be equal and so also need not be tested.
ignat_s
Posts: 8
Joined: Sun Jul 01, 2012 1:16 am

nice bijection

Post by ignat_s »

I was having really hard time understanding where 25 comes from. (Now I understand what you guys meant.) I found out an interesting fact: the function discussed (let's denote it a(n), so that a(4)=25, a(7)=966, and a(12)=261625 ) turns out to be exactly the Stirling numbers of the second kind S(n+1,3). I.e. a(4) = S(5,3) counts the number of ways to split a set of 5 elements into 3 disjoint nonempty subsets:

[ [ 1 ], [ 2 ], [ 3, 4, 5 ] ],
[ [ 1 ], [ 2, 3 ], [ 4, 5 ] ],
[ [ 1 ], [ 2, 3, 4 ], [ 5 ] ],
[ [ 1 ], [ 2, 3, 5 ], [ 4 ] ],
[ [ 1 ], [ 2, 4 ], [ 3, 5 ] ],
[ [ 1 ], [ 2, 4, 5 ], [ 3 ] ],
[ [ 1 ], [ 2, 5 ], [ 3, 4 ] ],
[ [ 1, 2 ], [ 3 ], [ 4, 5 ] ],
[ [ 1, 2 ], [ 3, 4 ], [ 5 ] ],
[ [ 1, 2 ], [ 3, 5 ], [ 4 ] ],
[ [ 1, 2, 3 ], [ 4 ], [ 5 ] ],
[ [ 1, 2, 4 ], [ 3 ], [ 5 ] ],
[ [ 1, 2, 5 ], [ 3 ], [ 4 ] ],
[ [ 1, 3 ], [ 2 ], [ 4, 5 ] ],
[ [ 1, 3 ], [ 2, 4 ], [ 5 ] ],
[ [ 1, 3 ], [ 2, 5 ], [ 4 ] ],
[ [ 1, 3, 4 ], [ 2 ], [ 5 ] ],
[ [ 1, 3, 5 ], [ 2 ], [ 4 ] ],
[ [ 1, 4 ], [ 2 ], [ 3, 5 ] ],
[ [ 1, 4 ], [ 2, 3 ], [ 5 ] ],
[ [ 1, 4 ], [ 2, 5 ], [ 3 ] ],
[ [ 1, 4, 5 ], [ 2 ], [ 3 ] ],
[ [ 1, 5 ], [ 2 ], [ 3, 4 ] ],
[ [ 1, 5 ], [ 2, 3 ], [ 4 ] ],
[ [ 1, 5 ], [ 2, 4 ], [ 3 ] ]

The part containing the element 'n+1' (i.e. '5' above) can be omitted, and the resulting list will be exactly the set of all pairs of disjoint subsets of 1...n.
Image
User avatar
hk
Administrator
Posts: 12832
Joined: Sun Mar 26, 2006 10:34 am
Location: Haren, Netherlands

Re: Problem 106

Post by hk »

Ah well, the number of possible subset pairs it given anyway.
Image
War ruins the life and health of untold numbers of innocent children.
larryleinweber
Posts: 4
Joined: Sat Sep 20, 2014 4:51 pm

Problem 106 Clarification

Post by larryleinweber »

Problem 103, 105 and 106 each begin by stating "Let S(A) represent the sum of elements in set A of size n." The problems indicate that elements can be summed and compared and examples are provided, but it never stated that the elements are numbers. Problem 103 states "If S(A) is minimised for a given n, we shall call it an optimum special sum set," but does not state that the numbers must be positive, and integers, except by example. Problem 106 states that "we shall assume that a given set contains n strictly increasing elements," although the elements of a set have no order. The wanted term is "sequence." The ultimate clarification, unfortunately, is that without these inferences, the official correct result cannot be obtained. Is there an FAQ anywhere that states the apparent default assumption that everything is a positive integer?
Guvante
Posts: 3
Joined: Wed Jul 24, 2013 10:34 pm

Re: Problem 106 Clarification

Post by Guvante »

larryleinweber wrote:Problem 103, 105 and 106 each begin by stating "Let S(A) represent the sum of elements in set A of size n." The problems indicate that elements can be summed and compared and examples are provided, but it never stated that the elements are numbers. Problem 103 states "If S(A) is minimised for a given n, we shall call it an optimum special sum set," but does not state that the numbers must be positive, and integers, except by example. Problem 106 states that "we shall assume that a given set contains n strictly increasing elements," although the elements of a set have no order. The wanted term is "sequence." The ultimate clarification, unfortunately, is that without these inferences, the official correct result cannot be obtained. Is there an FAQ anywhere that states the apparent default assumption that everything is a positive integer?
You cannot have any negative or zero integers while satisfying the second condition. Given the set of 4 -1, b, c, d for some 0 < b < c < d we can trivially break it using -1 + b < c when any subset of size 2 must be larger than any element. Similarly for all negative numbers a < b < c < d < 0 implies a + b < c. Finally 0 < b < c < d has 0 + b < c.
jneb
Posts: 2
Joined: Mon Jul 11, 2016 9:51 am

Re: nice bijection

Post by jneb »

[quote="ignat_s"]the function discussed (...) turns out to be exactly the [***] numbers.

Please don't do that. You spoil the fun for others.
jimfan
Posts: 20
Joined: Fri Sep 29, 2017 4:09 pm

Re: Problem 106

Post by jimfan »

I cannot explain why... This question appears to be a riddle more than a mathematics / programming challenge...
Image
User avatar
RishadanPort
Posts: 79
Joined: Mon Jun 10, 2013 7:31 am

Re: Problem 106

Post by RishadanPort »

I just want 1 clarification.

The elements of the set dont have to be whole numbers?

Its a bit confusing as the other questions have only integers.
Image

Rishada is the gateway to free trade—but the key will cost you.
User avatar
hk
Administrator
Posts: 12832
Joined: Sun Mar 26, 2006 10:34 am
Location: Haren, Netherlands

Re: Problem 106

Post by hk »

RishadanPort wrote: Sun Jun 20, 2021 4:45 am I just want 1 clarification.

The elements of the set dont have to be whole numbers?

Its a bit confusing as the other questions have only integers.
No they're integers.
Image
War ruins the life and health of untold numbers of innocent children.
kkm000
Posts: 3
Joined: Mon Oct 18, 2021 12:16 am

Re: Problem 106

Post by kkm000 »

hk wrote: Sun Jun 20, 2021 9:13 am No they're integers.
hk, I assumed that they were natural numbers, not integers. If they aren't, then this problem is not related to the problem 103, because, if we assume ℤ and not ℕ in the problem 103, then an SSS with a minimal sum either does not exist (i.e., you can always find one with a more negative sum than a given one), or smaller for an SSS being subset of ℤ than that of ℕ. My solution checked out, so I assume than the minimal-sum SSS in the problem 103 is a subset of ℕ. So, please clarify,

(a) Are they integers or natural number for the problem 106?
(b) Are they integers or natural number for the problem 103?

Thanks for the clarification!
User avatar
hk
Administrator
Posts: 12832
Joined: Sun Mar 26, 2006 10:34 am
Location: Haren, Netherlands

Re: Problem 106

Post by hk »

Please consider the consequences of the second condition.
Image
War ruins the life and health of untold numbers of innocent children.
kkm000
Posts: 3
Joined: Mon Oct 18, 2021 12:16 am

Re: Problem 106

Post by kkm000 »

hk wrote: Mon Oct 18, 2021 9:26 am Please consider the consequences of the second condition.
True. Thanks.
hamsterofdeath
Posts: 20
Joined: Fri Apr 27, 2018 7:17 pm

Re: Problem 106

Post by hamsterofdeath »

Hi, I'm totally lost on this one.
I have a set of numbers of size 4.
According to my Java knowledge, sets don't allow duplicates nor do they have an order, but in this thread here people were talking about sets like '1222' (as an example for a 4 element set)

So my first question is: what are valid sets for 106, and which sets aren't valid?

Thrn, how can there be 25 possible pairs of subsets?
Because I count:
1,2 ,3,4,12,13,14,23,24,34,123,124,234,134 which is 14, not 25.

And what does it mean when rule 1 doesn't need to be checked? When is it necessary, why isn't it always necessary?
DJohn
Posts: 90
Joined: Sat Oct 11, 2008 12:24 pm

Re: Problem 106

Post by DJohn »

1222 is mentioned in one post, as part of a reply to someone asking how to obtain the number of pairs of subsets. It is not a set, or an element of a set, but part of one method of enumerating subset pairs.

If we have a set with four elements A = { a, b, c, d } and we want to find all of the subsets of it, one way we can do this is by writing all 16 four-digit strings of 0 and 1: 0000, 0001, 0010, 0011, ..., 1111. Each digit corresponds to an element of A. If it is 1, we include that element in this subset. If it is 0, we don't. That gives us the 16 subsets {}, {a}, {b}, {a, b}, ..., {a, b, c, d}.

For this problem, we want pairs of disjoint subsets. We can do this by writing four-digit strings of 0, 1, and 2. If a digit is 1, that element goes in one subset. If it is 2, it goes in the other. If it is 0, it goes in neither. The subsets are non-empty, so we must have at least one 1 and one 2 in the string. Finally, we want the first non-zero digit to be 1 to avoid double-counting: the pair {a,b} and {c,d} is the same as the pair {c,d} and {a,b}, and we only want to count it once. Under those conditions, you will find that there are 25 possible strings, and so there are 25 subset pairs.

That's only one method of enumerating subset pairs. Nothing in the problem statement requires that you use it. It's just an easy way (for people who are used to this sort of method) of seeing that there are 25 subset pairs for a 4 element set.


For your second question: This method requires some way of mapping positions in the string to elements of the set. It gives them an order that the set itself doesn't have. If you make that order "increasing numerically" (so elements corresponding to earlier digits in the string are less than later digits), then for some pairs you know in advance that the sums can't be equal. In my example above, since a < b < c < d, it is impossible for a+b = c+d. We don't need to check equality for that subset pair. But for {a,d} and {b,c}, we do need to check, because the answer depends on the particular values of the elements of A: if A is {1, 2, 3, 4} then 1+4 = 2+3. But if A was {1, 2, 3, 5}, 1+5 /= 2+3.
Post Reply