in reply to Passing a complex array to a function
This code prints two rows of three columns. The first row is Camille, Jane, and Martha; the second row is the money of their respective husbands, whose names can then be determined by the allotment clues.# solving math puzzles with regexes is FUN! ("." x 10_000) =~ m{ ^ # camille (.{0,3960}) (?(?{ length($1) >= 3960 })(?!)) # june (.{100} \1) (?(?{ length($1.$2) >= 3960 })(?!)) # martha (.{100} \2) (?(?{ length($1.$2.$3) != 3960 })(?!)) (?{ print join(" ", map length, $1, $2, $3), "\n" }) (?: \1 (?: \2 \2 (??{ ".{" . 1.5*length($3) . "}" }) $ (?{ print join(" ", map .5 * length, $1 x 2, $3 x 4, $2 x 3), +"\n" }) | \3 \3 (??{ ".{" . 1.5*length($2) . "}" }) $ (?{ print join(" ", map .5 * length, $1 x 2, $2 x 4, $3 x 3), +"\n" }) ) | \2 (?: \1 \1 (??{ ".{" . 1.5*length($3) . "}" }) $ (?{ print join(" ", map .5 * length, $2 x 2, $3 x 4, $1 x 3), +"\n" }) | \3 \3 (??{ ".{" . 1.5*length($1) . "}" }) $ (?{ print join(" ", map .5 * length, $2 x 2, $1 x 4, $3 x 3), +"\n" }) ) | \3 (?: \1 \1 (??{ ".{" . 1.5*length($2) . "}" }) $ (?{ print join(" ", map .5 * length, $3 x 2, $2 x 4, $1 x 3), +"\n" }) | \2 \2 (??{ ".{" . 1.5*length($1) . "}" }) $ (?{ print join(" ", map .5 * length, $3 x 2, $1 x 4, $2 x 3), +"\n" }) ) ) }x;
_____________________________________________________
Jeff[japhy]Pinyan:
Perl,
regex,
and perl
hacker.
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Passing a complex array to a function
by particle (Vicar) on Jan 26, 2002 at 11:58 UTC | |
by japhy (Canon) on Jan 26, 2002 at 12:52 UTC | |
|
Re: Re: Passing a complex array to a function
by trs80 (Priest) on Jan 26, 2002 at 11:43 UTC |