Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C Moderated > Re: Arithmetic ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 5 of 7 Topic 1006 of 1134
Post > Topic >>

Re: Arithmetic expression fitting algorithm?

by Barry Schwarz <schwarzb@[EMAIL PROTECTED] > Jan 12, 2008 at 04:43 PM

On 21 Sep 2007 05:15:30 GMT, Icebeing <spamtronic@[EMAIL PROTECTED]
> wrote:

>Hi all,
>
>   Some time ago, I got hit with this problem on a game-programming
>test, and it's bugged me ever since:
>
>The program has 2 inputs:
>
>1 32-bit integer, called result
>1 input string of digits
>
>The algorithm calls to construct an arithmetic expression string from
>the input string so that it evaluates to the result value, by
>inserting '+' and '*'
>
>example:
>
>input 1 = 44550
>input 2  = "8888225"
>
>algorithm spits out:  "8888+22*5"

Considering that this expression evaluates to 8998 and not 44550, why
would you want to do this.

>
>the algorithm spits out "" if no arithmetic expression can "fit" input
>2 with input 1
>
>best approach i could come up with is a brute-force method...any math-
>heads know a better approach to this?
>my number theory is rusty lol
>
>many thanks, charles!


Remove del for email
-- 
comp.lang.c.moderated - moderation address: clcm@[EMAIL PROTECTED]
 -- you must
have an appropriate newsgroups line in your header for your mail to be
seen,
or the newsgroup name in square brackets in the subject line.  Sorry.
 




 7 Posts in Topic:
Arithmetic expression fitting algorithm?
Icebeing <spamtronic@[  2007-09-21 05:15:30 
Re: Arithmetic expression fitting algorithm?
"Douglas A. Gwyn&quo  2008-01-12 16:41:57 
Re: Arithmetic expression fitting algorithm?
Tim Brown <timbrown@[E  2008-01-12 16:42:33 
Re: Arithmetic expression fitting algorithm?
=?ISO-8859-1?Q?Hans-Bernh  2008-01-12 16:42:59 
Re: Arithmetic expression fitting algorithm?
Barry Schwarz <schwarz  2008-01-12 16:43:23 
Re: Arithmetic expression fitting algorithm?
Kevin Ashley <K.Ashley  2008-01-12 16:44:30 
Re: Arithmetic expression fitting algorithm?
Barry Schwarz <schwarz  2008-01-12 16:48:18 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 16:00:38 CDT 2008.