Board index   FAQ   Search  
Register  Login
Board index PHP PHP General

given number and multiple matching

General discussions related to php

Moderators: macek, egami, gesf

given number and multiple matching

Postby karli » Wed Nov 14, 2012 6:11 am

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
New php-forum User
 
Posts: 3
Joined: Wed Nov 14, 2012 5:51 am

Re: given number and multiple matching

Postby seandisanti » Wed Nov 14, 2012 8:54 am

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
php-forum Fan User
 
Posts: 838
Joined: Mon Oct 01, 2012 12:32 pm

Re: given number and multiple matching

Postby karli » Wed Nov 14, 2012 9:41 am

thank you seandisanti for your reply.
every working combination will be great.
karli
New php-forum User
New php-forum User
 
Posts: 3
Joined: Wed Nov 14, 2012 5:51 am

Re: given number and multiple matching

Postby seandisanti » Wed Nov 14, 2012 9:54 am

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
php-forum Fan User
 
Posts: 838
Joined: Mon Oct 01, 2012 12:32 pm

Re: given number and multiple matching

Postby karli » Wed Nov 14, 2012 11:01 am

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
New php-forum User
 
Posts: 3
Joined: Wed Nov 14, 2012 5:51 am

Re: given number and multiple matching

Postby lanshan75 » Sat Dec 08, 2012 10:17 pm

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
New php-forum User
 
Posts: 2
Joined: Sat Dec 08, 2012 10:14 pm


Return to PHP General

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.