Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Following blakem's rules,
# 1 2 3 #234567890123456789012345678901234567 $"='';grep{/^(([@_])(?!.*\2))+$/}<D>;
37 characters! I'm pleased with my first try at golfing. ;)

andy.

PS stuffy, good choice of puzzle! There went my lunchtime.

update: 36

#234567890123456789012345678901234567 $"='';grep/^(([@_])(?!.*\2))+$/,<D>;
update 2: Thanks dragonchild, 35 w/out the ;
Hmm... you're right about the duplicate letters. I can't remember whether these appear on the t.v. show - I rather suspect they do.

update, later:
This cope with duplicates, but is a lot longer:

# 1 2 3 4 5 6 7 + 8 #234567890123456789012345678901234567890123456789012345678901234567890 +12345678901 $"='';$n{$_}++for@_;grep/^((??{"([@_])"})(??{"(?!([^$1 ]*$1){$n{$1},}) +"}))+$/,<D>
(you need to use re 'eval')
I'd rather do:
$"='';$n{$_}++for@_;grep/^(([@_])(??{"(?!([^$1 ]*$1){$n{$1},})"}))+$/, +<D>
(the difference being that @_ is interpolated normally here), but for some reason this isn't allowed - I get back Eval-group in insecure regular expression in regex - no idea why, since I'm using re 'eval', and @_ surely can't be tainted?

Going to dinner. andy.


In reply to andye Re: "Countdown" (golf) by andye
in thread "Countdown" (golf) by stuffy

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-03-29 07:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found