Search found 18 matches

by albert_nik
Sat Aug 20, 2016 9:21 am
Forum: Combinatorics
Topic: Urns and balls
Replies: 0
Views: 3318

Urns and balls

We have some urns (u1 u2 u3 u4) with different number of red and black balls (r1 b1), (r2 b2)... and we select one ball from each 1.The number of ways to get all 4 balls red is r1*r2*r3*r4 . 2.The number of ways to have 3 reds and 1 black is r1*r2*r3*b4 +r1*r2*b3*r4+r1*b2*r3*r4+b1*r2*r3*r4. 3.The nu...
by albert_nik
Thu Oct 01, 2015 12:48 pm
Forum: Combinatorics
Topic: Sum of products of n-tuples
Replies: 3
Views: 3471

Re: Sum of products of n-tuples

jaap wrote:Isn't it just this?
Expand
(a1+a2+a3+..+an)*(b1+b2+...+bn)*(c1+c2+...+cn)
Expand
I feel so stupid :oops:
by albert_nik
Thu Oct 01, 2015 8:53 am
Forum: Combinatorics
Topic: Sum of products of n-tuples
Replies: 3
Views: 3471

Sum of products of n-tuples

Let's say I have an array of numbers {a,b,c,d,e} and want to calculate the sum of product of all triples abc+abd+...+cde. I can calculate it very fast without generating all triples using this formula F(n,k)= v[k]*F(n-1, k-1)+ F(n-1, k) with two loops int[] values={a, b, c, d, e...}; int k = 3; int[...
by albert_nik
Wed May 28, 2014 10:47 am
Forum: Combinatorics
Topic: Set containing max number of subsets
Replies: 11
Views: 6266

Re: Set containing max number of subsets

Thank You jaap. The idea was from a lottery game (keno). There are 80 numbers [1..80] and are selected randomly 20 numbers. A player can select 1 to 8 numbers. If the player's numbers are all included in the 20 he wins. There are N players that have selected some sets with 1<=size<=8. The task is to...
by albert_nik
Tue May 27, 2014 6:25 am
Forum: Combinatorics
Topic: Set containing max number of subsets
Replies: 11
Views: 6266

Re: Set containing max number of subsets

I tried starting from empty set, adding subset A, then B, A∪B, C , A∪C, B∪C , A∪B∪C, D ... removing duplicates(same unions with same number of subsets) and those with size >20.
This can work for a few subsets, but the list grows rapidly.
Checking each of 100!/(80!*20!) subsets is impossible also.
by albert_nik
Sun May 25, 2014 2:31 pm
Forum: Combinatorics
Topic: Set containing max number of subsets
Replies: 11
Views: 6266

Re: Set containing max number of subsets

Doesn't have every set of size n have the same number of subsets? (2^n) Yes. I mean we have some (not all) singles, doubles, triples, 4-uples and 5-uples {1} , {25}, {2,30}, {1,2,3}, {3, 20, 50}, {40,50,60,70}, {1,2,3,4,5} ...(they are less than Cnk(100, 1)+Cnk(100, 2)+Cnk(100, 3)+Cnk(100, 4)+Cnk(1...
by albert_nik
Sun May 25, 2014 11:45 am
Forum: Combinatorics
Topic: Set containing max number of subsets
Replies: 11
Views: 6266

Set containing max number of subsets

Let's say we have the set of numbers [1..100] and some subsets with size<=5.
{1} , {25}, {2,30}, {1,2,3}, {3, 20, 50}, {40,50,60,70}, {1,2,3,4,5}....
Is it some efficient method to find a set of size=20 το contain the most sets?
by albert_nik
Sun Dec 29, 2013 5:26 pm
Forum: Number
Topic: Limit average speed using delays
Replies: 0
Views: 1596

Limit average speed using delays

Hello, This question is more mathematical than programmatical (althougth I wrote quite enough code :D ), so I decided to post it here. I have an application that reads data from the web and I want to implement a speed limit feature The program gets the stream in packets inside a while loop until has...
by albert_nik
Tue Sep 17, 2013 6:55 pm
Forum: Number
Topic: An priority algorithm
Replies: 2
Views: 1768

Re: An priority algorithm

I want to implement an IncreasePriority algorithm that takes as arguments a collection of elements ( e.g. IncreasePriority of 25th, 35th, and 37th elements). Thank you. Can't you just call the single-element version several times, once for each element in your collection? The only thing to be caref...
by albert_nik
Tue Sep 17, 2013 5:28 pm
Forum: Number
Topic: An priority algorithm
Replies: 2
Views: 1768

An priority algorithm

I have an int[N] array, each element has a unique value 1 to N. I want to implement a IncreasePriority function (add 1 to the selected element and remove 1 to the element that had that value, so all elements have unique values). Increasing priority of a single element is easy. Add 1 (if is less than...
by albert_nik
Fri Nov 23, 2012 8:15 am
Forum: Combinatorics
Topic: Maximising sum of products
Replies: 4
Views: 3990

Re: Maximising sum of products

I think this can be a possible PE problem
Expand
Find the 1000000-th bigest sum...
by albert_nik
Thu Nov 22, 2012 9:47 pm
Forum: Combinatorics
Topic: Maximising sum of products
Replies: 4
Views: 3990

Re: Maximising sum of products

Thank you both kevinsogo and thundre.
You helped me a lot.
by albert_nik
Thu Nov 22, 2012 11:21 am
Forum: Combinatorics
Topic: Maximising sum of products
Replies: 4
Views: 3990

Maximising sum of products

Lets say we have x1, x2 ...x n and y1,y2, ...yn all >0. I want to maximize the sum of pair products (i.e. x1*y2+x4*y1 +x2*y3+...) Since there are n! combinations we cannot find all sums. Is there some efficient method to find the first k (k=10 or 100) bigest sums? If I sort X and Y , taking the prod...
by albert_nik
Tue Aug 28, 2012 1:09 pm
Forum: Clarifications on Project Euler Problems
Topic: Problem 295
Replies: 7
Views: 2057

Re: Problem 295

Both sides >1 ?
by albert_nik
Tue Aug 28, 2012 10:39 am
Forum: Clarifications on Project Euler Problems
Topic: Problem 295
Replies: 7
Views: 2057

Re: Problem 295

Continuing with the same reasoning I count:
  • for N=10 --> 31 shapes and 30 distinct pairs.
    for N=100 --> 3330 shapes and less than 3330 distinct pairs.
Are there some other pairs that I'm missing?
by albert_nik
Sat Jul 07, 2012 6:42 pm
Forum: Clarifications on Project Euler Problems
Topic: Problem 283
Replies: 7
Views: 2568

Re: Problem 283

Hello,
For (area/perimeter) <= 100 is sum of the perimeters 289620027474 ?
Thank You.
by albert_nik
Sun May 09, 2010 9:17 pm
Forum: Clarifications on Project Euler Problems
Topic: Problem 288
Replies: 14
Views: 4740

Re: Problem 288

Yes, i get this too: NF(61,10^6) mod 61^9 = 1075175834078238

Maybe you have same problem with me.
If you are using
long m = (long) Math.Pow(61,10) // gives m= 713342911662882560 !!!!
check this :
61^9 = 11694146092834141
61^10=713342911662882601
by albert_nik
Wed Sep 30, 2009 6:16 am
Forum: Clarifications on Project Euler Problems
Topic: Problem 257
Replies: 5
Views: 2389

Problem 257

Hi, can anyone confirm for (a+b+c<=10000) number of triangles is 7677

Thank you!