in reply to Puzzle: Given an array of integers, find the best sequence of pop / shift...
Update: Tilly shot a hole in that strategy, so I'll try again here rather than proliferating response nodes. If the number of nodes is fewer than 6, the above strategy should hold. For > 6, a b c ... d e f, calculate the differences a-b, b-c, e-d, and f-e. Call the "current score" of the field a-b + f-e. Depending on whether you shift or pop, the "new score" would be a-b + e-d or b-c + f-e. Choose whichever makes the bigger negative difference (changing the game the most to your opponent's disadvantage).
Update 2: But it still doesn't get the best result for the example data. :-(
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Puzzle: Given an array of integers, find the best sequence of pop / shift...
by tilly (Archbishop) on Mar 20, 2006 at 22:34 UTC | |
|
Re^2: Puzzle: Given an array of integers, find the best sequence of pop / shift...
by tilly (Archbishop) on Mar 20, 2006 at 18:39 UTC |