The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
April 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Recursive Countdown Numbers Game (Close enough)

Posted by Andy C on April 06, 2001 at 3:19 PM

I'm pretty new at this Java stuff, and basically I have a problem. I'm trying to generate a set of postfix expressions, involving 6 numbers and the 3 operators *, +, and -. I deal with up to only 5 out of the 6 numbers in any one expression, no number is repeated in an expression (unless it appears more than once in the actual 6 numbers), and each operator can be used more than once. The idea is to produce any valid postfix expression that produces an answer between 0 and a target number, which is provided. I have a recursive algorithm which generates valid postfix expressions, but unfortnately there are some expression formats which it does not generate, and others which it duplicates - I know why, I just don't know how to get around it, this is my 6th version, and I'm getting pretty fed up with it, can anyone give me some advice on how to go about solving this problem (it needs to be fast as well, ideally). Thanking you in advance.



Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us