develooper Front page | perl.fwp | Postings from July 2003

Re: Fun - Each character at most once

A. Pagaltzis
July 17, 2003 14:49
Re: Fun - Each character at most once
Message ID:
* <> [2003-07-17 21:15]:
> > What is the most "interesting" program that is restricted to
> > use each ASCII character at most once?
> The definition I chose was to check if a program (from @ARGV)
> contains duplicate chars and  printing a duplicate char iff it
> has one.

Even ++, --, ==, && etc are illegal. A substitution based
approach is about impossible - you need a dot in several places
of the pattern, and if you have backreference you'll likely need
a capture variable with the same number in the replacement
expression as well. And finally, you can't refer to any variable
more than once.

That final one is the kicker.

Basically, with all ASCII characters used at most once, you can't
really write anything that needs to actually operate on data in
any more but the most trivial ways.

Aristotle Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About