### Re: Brute force perl

by toma (Vicar)
 on Jun 12, 2007 at 17:16 UTC ( #620769=note: print w/replies, xml ) Need Help??

in reply to Brute force perl

Challenge: generate the numbers 0 to 100 using math expressions composed of only the characters +-/*4() . Find the minimum length expression for each number from 0 to 100. These might be the first few numbers:
```0: 4-4
1: 4/4
2: 4/4+4/4
3: 4-4/4
4: 4
...

The minimum length of these expressions would make an easy fitness function if you wanted to experiment with GA.

I originally heard this problem as a math-golf-type challenge to a fifth and sixth grade math club.

I don't remember the algorithm that I ended up using, but I do recall writing a generator that created valid expressions, so that the code wouldn't try to eval things like 4-( as an expression.

It should work perfectly the first time! - toma

Replies are listed 'Best First'.
Re^2: Brute force perl
by jdporter (Canon) on Jun 12, 2007 at 20:18 UTC

This is actually a textbook example of a genetic programming problem. Of course, you could attack it with GA, but GP is a much better fit.

Create A New User
Node Status?
node history
Node Type: note [id://620769]
help
Chatterbox?
 [marto]: good morning all [Corion]: Hi marto! [Corion]: I just found out that in \$current_top_prior ity_project , the part I am in is not even in the top three worries. That's somewhat bad, not because I'm happy with being a top worry but because that means that I don't even know how bad the rest ... [Corion]: ... of the situation is :-)

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2017-07-26 08:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
I came, I saw, I ...

Results (385 votes). Check out past polls.