in reply to The greedy change-making problem using regexes
I'd approach it inside out. I'd make my regex try to match like so:
Then I'd add to that regex code blocks that store the "winning" combination. The concept is, it tries to match the string using only one coin. Once that fails, it tries to match it using two coins. Etc. This is probably slow.("1" x $money) =~ /^(1{10}|1{6}|1{5}|1{1}){1,}?$/
Hrm, this probably won't work easily with Perl's regexes. My first efforts have proved fruitless.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: The greedy change-making problem using regexes
by blokhead (Monsignor) on Mar 10, 2005 at 02:00 UTC | |
Re^2: The greedy change-making problem using regexes
by demerphq (Chancellor) on Mar 10, 2005 at 07:46 UTC | |
by theorbtwo (Prior) on Mar 10, 2005 at 11:02 UTC | |
Re^2: The greedy change-making problem using regexes
by Anonymous Monk on Mar 10, 2005 at 10:45 UTC | |
by japhy (Canon) on Mar 10, 2005 at 12:32 UTC | |
by Anonymous Monk on Mar 10, 2005 at 13:14 UTC |
In Section
Meditations