Programming Contest: Efficient Editor Usage
Fred (a.k.a. The POTM-MASTER) writes "Anyone can write editors, but it's surprisingly hard to write a program to USE an editor. This latest Programming challenge asks you to write a program that will change one block of text into another using a simple set of 'vim-like' editor commands." (Find the details here.) "Deadline is May 31, 2005 so you've got plenty of time. The POTM is the 'Programmer Of The Month' contest - newly revived and active with about 1000 folks registered for the forums. It is completely for fun - unsponsored and prize-less except for the fame!"
Hardly vim-like... It's missing all the useful stuff like f F t T, all text objects and motions and all the modal stuff. These're the things that make vim so much more powerful than anything else.
But then, I guess "using a few simple manipulation commands" doesn't sound as sexy, eh?
should be changed to a contest to find the most efficient way to do the job. I wrote such a job finisher years ago, and it is used by myself and others to check Project Gutenberg texts.
And my method is capable of learning.
Don't forget to copyright and patent your brilliant idea before you submit it. Microsoft might use it in Longhorn and then sue you later.
i saw this already on slashdot
Just use sed, like a RealMan.
Trolling is a art,
This latest Programming challenge asks you to write a program that will change one block of text into another using a simple set of 'vim-like' editor commands."
Hmm... change one block of text into another with editor commands. So we'd need an editor... let's call it 'ed'... and we'd need it to operate on a stream rather than a file... so I suppose we could call it 'sed'. Quite frankly, I'm amazed that nobody has thought of this before.
>aNEWLINEGOESHEREd>aNEXTLINEGOESHERE
:)
I'm thinking this may be the most efficient for really different sets of files.
"'vim-like' editor commands"
Oh no. Don't tell the emacs people about this...
Coder's Stone: The programming language quick ref for iPad
I think an obvious approach here is to use a genetic algorithm - literally breed the best collection of editting commands to generate the output.
Reading the rules says that there is a time limit of 60 seconds per program, so it might not be the best approach in reality - but it might be a fun way to attack the problem.
So what's the deal with this?
Use the edit distance algorithm and find all traces transforming the source string into the target string. Then go through all traces and try to chunk them into as big "editing chunks" as possible, which depends on whatever the editing operations they permit.
into this
Even though the shared substring takes up most of the example, trying to preserve it makes for an expensive solution (because of the penalty for inserting characters in front). Of course one can insert in the second position much more cheaply than the first, but it "ruins" the substring that starts in the zeroth column.In fact, I'm sort of starting to wonder if finding "the solution" to this problem is intractable (at least for the specified input sizes and CPU time max). This means that heuristics are the name of the game, and the problem does lend itself to some interesting ones.
Indeed. Particularly intriguing is the topological characteristic that it is fast and cheap to jump (or even delete) one's way to the start or end of a line, but expensive to get to a place in the middle. One can wormhole around this by virtue of having lines of different lengths to go into and out of (as alluded to in parent). A final strategic observation is that as one starts to close in on the endgame, and the strings start to get long again (short strings at the beginning make for less maneuvering), one would like to be more or less appending things to the end.Can anyone come up with a convincing argument that the single-line subproblem is easy/hard?