## given number and multiple matching

General discussions related to php

Moderators: macek, egami, gesf

### given number and multiple matching

I've tried to solve the problem for some time but still do not know how to do it, must ask for help.
There is given number and array, given number must match with array value (preferable) OR array values.

//EXAMPL 1
\$gn=10;
\$seq=array();
\$seq["A"]=2;
\$seq["B"]=2;
\$seq["C"]=12;
\$seq["D"]=6;
//OUTPUT MUST BE "A","B" and "D" because 2+2+6=\$gn and 12!=10

//EXAMPL 2
\$gn=10;
\$seq=array();
\$seq["A"]=1;
\$seq["B"]=9;
\$seq["C"]=10;
\$seq["D"]=3;
//OUTPUT MUST BE "C" because 10=\$seq and 1+9 are not preferable.

Does anyone have an idea of ​​how it might be solved?
karli
New php-forum User

Posts: 3
Joined: Wed Nov 14, 2012 5:51 am

### Re: given number and multiple matching

1) is this for a challenge site? i'll still help, just curious because i am always on the look out for new challenges.

2) do you need to return every working combination, or any working combination?
seandisanti
php-forum Fan User

Posts: 681
Joined: Mon Oct 01, 2012 12:32 pm

### Re: given number and multiple matching

every working combination will be great.
karli
New php-forum User

Posts: 3
Joined: Wed Nov 14, 2012 5:51 am

### Re: given number and multiple matching

you didn't answer number 1 and i see the answer to number 2 in re-reading your original post.
seandisanti
php-forum Fan User

Posts: 681
Joined: Mon Oct 01, 2012 12:32 pm

### Re: given number and multiple matching

No, its not intended to challenge anyone you. I just have a problem to my accounting program and do not know how to solve it. Any help is appreciated. Like I said, there is a number, which must be equal to the others (array)
karli
New php-forum User

Posts: 3
Joined: Wed Nov 14, 2012 5:51 am

### Re: given number and multiple matching

Very glad to meet everybody here,I am just a new member of this forum,I want to make more friends here,I hope you can like me.
____________________________________
share love,share happy,share useful information about Buy WOW Gold and RS Gold
lanshan75
New php-forum User

Posts: 2
Joined: Sat Dec 08, 2012 10:14 pm