07.14.06

TMQ 1

Posted in TextMate at 8:02 pm by Haris

This is the first TextMate Quiz. Please read the rules here.

Your problem is as follows. In a folder under your home directory, let’s call it “My Files” (notice the space there), are a number of image files, plus some other files. Update: Here is a sample folder to work from.

Here is a typical listing of the folder:

mytexfile.tex
fig2.jpg
figure01.jpeg
ast-yu4c.JPG
some random stuff.markdown
a5s hj4b.jpg
Figure13.jpeg
.... about 30 more files of this type.

The quiz has two parts. On the first part, you have to rename the files on this folder with the extensions jpg or jpeg, in any capitalization, so that the files

figure01.jpeg
fig2.jpg
a5s hj4b.jpg
ast-yu4c.JPG
Figure13.jpeg
....

become

figure01.jpg
figure02.jpg
figure03.jpg
figure04.jpg
figure05.jpg
....

in that order. In other words, we order the file according to what follows right before the extension. It is a number, possibly followed by a single letter. We order first by the number, and if the two numbers are the same then by the letter. So in the above, the order is as demonstrated because 1<2<4b<4c<13. The number of digits used should be just enough to cover the number of image files, which could be up to 99. This is the first part of the quiz.

Make sure to include in your answer the total number of keystrokes for this first part. The best answer to this part will receive individual honorary mention.

The second part of the quiz is to add, at the end of the file mytexfile.tex mentioned above figure environments, one for each of these figures. Here is how the figure environment for the first figure would look:

\begin{figure}[htbp]
    \begin{center}
    \includegraphics[scale=1]{figure01.jpg}
  \end{center}
  \caption{The figure01 caption}
  \label{fig:figure01}
\end{figure}

Note the appearance of the phrase figure01 in three different places. you need each figureNN to appear in those places.

Since I will be very busy until Sunday, August 13th, that’s when this quiz is due. So you get a whole month to work on it.

Enjoy!

7 Comments »

  1. Allan Odgaard said,

    July 15, 2006 at 1:15 am

    With the file listing you say that there are “about 30 more files of this” and the second part of the question asks to add figure environments for each.

    But the total number is only roughly know.

    I’d suggest actually creating these files (doesn’t have to contain anything) and put them up for download, also so that we have something to experiment with.

  2. Thomas Aylott said,

    July 15, 2006 at 2:31 am

    I concur. If we all have the same files to work from it would standardize things a bit, me thinks.

    Great / Evil idea for taking up our valuable free-time, thanks a lot ;)

  3. Haris said,

    July 15, 2006 at 5:56 am

    Quite right. There should be a link with the folder now.

  4. Haris said,

    July 15, 2006 at 5:58 am

    @Thomas,

    Great / Evil idea for taking up our valuable free-time, thanks a lot

    well, someone had to distract Michael Sheets from his commits for a while. ;)

  5. Gerd Knops said,

    July 18, 2006 at 11:04 am

    How about doing your own homework? ;-)

    I do not understand the meaning of “total number of keystrokes for this first part.” Do you mean shortest code? Shortest invocation sequence?

    And what is the point of the second part? It seems so trivial that I wonder if I am missing something.

  6. Haris said,

    July 18, 2006 at 11:19 am

    @Gerd,

    did you read the rules in the other post? That’s where I explain how to count, I hope. For commands that you write yourself, it is the length of the code. For built in commands, it is the number of keystrokes need to trigger the command. So if it has a key equivalent, then that’s 1 and so on.

    Overall, it’s the number of keypresses, without counting modifier keys, that you need in order to accomplish the entire task. If TextMate can help you to produce a lot of text with fewer keystrokes, then you can bring that number down. ;)

    As for the second part, it is not hard to do, but still we are looking for the fastest way to do it. You might be missing a quick way to generate the text you see there. ;)

    I am not saying any of this is hard, its purpose is to help people learn some of the tricks/commands that TM has to make our life easier. For anyone who hasn’t heard of commands before, there is a lot of stuff to do.

    And also, since selected answers will be published, you get to see the workflows of other people, which might be beneficial.

  7. Gerd Knops said,

    July 18, 2006 at 12:29 pm

    Ah, thanks for the clarification.

Leave a Comment