in reply to army building

A simple algorithm follows from this reasoning:

As a simple sloppy example, if you have only three types:

$p1 = ... # Price of figures of type 1 $p2 = ... # Price of figures of type 2 $p3 = ... # Price of figures of type 3 $budget = ... # Total budget for (my $i1=0; $i1 * $p1 <= $budget; $i1++) { for (my $i2=0; $i2 * $p2 <= $budget - $i1 * $p1; $i2++) { for (my $i3=0; $i3 * $p3 <= $budget - $i1 * $p1 - $i2 * $p2; $ +i3++) { print "You can buy $i1 type 1 + $i2 type 2 + $i3 type 3\n" +; } } }
Of course you should never code it this way and should instead be using arrays and an iteration which lends itself better to extensions. Anyway, I hope the algorithm is clear.

Cheers

Antonio

Update: I have taken for granted that you could use more than one figure of each type. If that assumption is not valid, please disregard the solution or add the additional condition that all indices ($i1, $i2 ...) should not exceed 1.

The stupider the astronaut, the easier it is to win the trip to Vega - A. Tucket