develooper Front page | | Postings from January 2007

simple golf for fun

Thread Previous | Thread Next
Phil Carmody
January 16, 2007 06:20
simple golf for fun
Message ID:
This is a real world task which can be solved in a couple of lines. 
Which makes me think that you guys can do it in about half a line!

The simple version of the task is to verify that each line of a file is the
insertion of one character somewhere (maybe at the start or the end) into the
prior line.

would be accepted, but
would not be accepted.

If that's too easy, or too short, the more advanced version of the task is for
each line to print which character has been inserted in which position for each

There's a lot of flexibility on how the verification result is reported to the
user, so you may, within sensible limits, do whatever's best. An error return
value, or printing a Y or N, or 1 or 0, or the line number on which it fails,
or anything like that would be fine. Similarly, whether you start counting at 0
or 1, I don't care, I can cope with both.

This is for a little bit of mathematical research I'm doing (so the lines in
the file will actually just be big numbers), and I will happily credit the
winner when I announce the results of the research. That'll be weeks away, but
I wouldn't want anyone to waste more than a short while on this task.


()  ASCII ribbon campaign      ()    Hopeless ribbon campaign
/\    against HTML mail        /\  against gratuitous bloodshed

[stolen with permission from Daniel B. Cristofani]

No need to miss a message. Get email on-the-go 
with Yahoo! Mail for Mobile. Get started. 

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