Kind of an interesting math problem. Since the points are all apparently interchangeable, you can start by adding everything up: You have 60+80+31=171 points, and you need 51+107+38=196. That leaves you 25 points short. You gain 12+17+7=36 per hour. So you'll need something under an hour to gain your points. 25/36 of an hour, to be exact.

Update: I interrupt my own post to point out that there is no reason to do a shuffle if you don't have enough total points. Just figure out how long you need to wait, wait that long, and then shuffle.

So shuffle your points to be 25/36 of an hour from having what you need:
HP: 50-(25/36)*12
Mana: 107-(25/36)*17
Spells: 38-(25/36)*7
should do it, not counting some rounding errors.

Update: here's some ham-handed code (updated again to optimize leftover placement):

# Have/gain per hour my @points = ([60,12,'HP'],[80,17,'Mana'],[31,7,'Spells']); my @need = (51, 107, 38); use List::Util qw(sum reduce); my $total_have = sum map $_->[0], @points; my $total_need = sum @need; print "You have $total_have and need $total_need\n"; my $diff_need = $total_need - $total_have; my $gain_per_hour = sum map$_->[1], @points; print "You need $diff_need more, and you gain them at $gain_per_hour p +er hour\n"; my $time_left = $diff_need/$gain_per_hour; print "That should take $diff_need/$gain_per_hour hour(s).\n"; my @new_values = map $need[$_] - $time_left * $points[$_][1], 0..$#nee +d; my $leftover = $total_have - sum map int, @new_values; # Put leftovers on furthest-from-goal while ($leftover--) { my $slow = reduce { $new_values[$a]-int($new_values[$a]) > $new_values[$b]-int($new_va +lues[$b]) ? $a : $b } 0..$#points; $new_values[$slow]++; } @new_values = map int, @new_values; for (0..$#need) { print "New value for $points[$_][2]: $new_values[$_]\n"; }

Caution: Contents may have been coded under pressure.

In reply to Re: Calculate easiest way to 'level results' by Roy Johnson
in thread Calculate easiest way to 'level results' by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.