Aucf-cs.461 net.games utcsrgv!utzoo!decvax!duke!ucf-cs!whm Tue Mar 9 21:16:54 1982 Vi Quiz Winner Announced Believe it not, the Vi quiz (see ucf-cs.336) answers have been tabulated and a winner has been found. The envelope please... The winner is Marty Rattner of National Semiconductor, nsc!marty. Marty pulled out all the stops and shaved the number of keystrokes for traversal of the gauntlet to a slim 99. Here are Marty's answers. Question No. Count Keystrokes 1) 2 5G 2) 2 -J 3) 1 D 4) 3 d5) 5) 1 u 6) 1 u [or .] 7) 4 c)? 8) 5 hd%e. 9) 5 dd4p 10) 6 30|11x 11) 5 HdLGp 12) 9 i/*A*/ 13) 1 ^G 14) 11 /thedd''. 15) 13 :se sw=12>9 16) 4 f,d; 17) 5 3A^V 18) 15 H!Ltr 0-9 1-90 19) 5 ~~~~~ 20) 1 U Total: 99 To refresh your memory, here's the test, with the answers merged. ----------------------------------------------------------------- (1) Move to the fifth line of the file. 5G (2) Append the current line to the end of the previous line. -J (3) Delete all of the current line that is not to the left of the cursor. D (4) You are editing a document and are positioned on the first character of a sentence. Delete the next five sentences. d5) (5) I'm sorry, get those last five sentences back where they were. u (6) I just can't make my mind up, get rid of those same five sentences. u (7) Change the next sentence to the single character "?". c)? (8) You are positioned on the y in "((x*3)-(y-(1*2*3(((())))))x*(i+(j*k))*z)", make it read: "((x*3)-x**z)". hd%e. (9) Move the next five lines to before the current line, retain the order of the five lines. dd4p (10) Delete characters 30 through 40 in the current line. Assume that there are more than 40 characters in the current line. 30|11x (11) Move all of the text that is visible on the screen to the end of the file. HdLGp (12) The next line in the file is: "x = x + 1;", change it to: "/*x = x + 1;*/". i/*A*/ (13) Find out what line you are on. ^G (14) Delete the next line in the file that contains the word "the" and then delete the line that you were on before you went looking for "the". /thedd''. (15) Starting with the current line, move the next ten lines 12 spaces to the right. You may insert tabs if you wish. :se sw=12>9 (16) Make the sentence "The machine, described in [Smith 80], was a complete failure." read "The machine was a complete failure." Assume you are on the "T". f,d; (17) Insert three backspaces after the last character of the current line. 3A^V (18) Change every instance of a digit, n, on the current screen, to (n+1) mod 10, that is, 0's to 1's, 1's to 2's, ... 9's to 0's. (Hint: This might be done using something in addition to the editor, but the editor is involved.) H!Ltr 0-9 1-90 (19) Change the string "hello" to "HELLO". Assume you are positioned on the "h". ~~~~~ (20) You have just finished making 300 changes in the current line in an as yet unsuccessful attempt to correct a one word spelling error. Make the line appear as it did before you went to work. U -------------------------------------------------------------------------- There were 28 entries, of which 12 (gi!lou, zehntel!berry, azure!randals, teklabs!larrym, pur-phy!rb&hal, cbosgd!mark, hoasa!rbr, uwvax!keith, IngVax:marc, csin!rona et. al., nsc!marty, and ucbvax!earl) had correct answers to all questions. The top finishers were: nsc!marty 99 azure!randals 100 pur-phy!rb&hal 102 IngVAX:marc 103 gi!lou 105 zehntel!berry 107 hoasa!rbr 109 csin!rona 109 IngVAX:arnold had 99 keystrokes but there was a slight interpretation problem on #12 and he got the short end of the stick. Steve Zimmerman did it using EMACS and got 91 keystrokes. (I must say though that my main complaint with EMACS is the extensive use of the control and escape keys, and if you count control and meta keys, and shifts as 2 keystrokes instead of 1, EMACS uses about 215 keystrokes while the winning Vi entry uses about 120 keystrokes. If you want to argue about Vi and Emacs, editor-p is the place.) As to the ideal answers, Marty seems to have the optimal answer for most of the questions, with the exception of #14, in which the leading could have been left out and still have passed my standards. Several questions deserve comment. On #8, the "e" operation is defined in some way to work consistently on expressions and was used to good advantage. Only two people used e "e" for their answer. Some people also used ct...$ sequences to fix the string. The question was rather contrived and artificial, but real points were to use the motion of the % to delete the enclosed expression and then use the . to repeat to the last action. Number 9 could be solved by deleting the next five lines and then putting them back before the current line, or by moving the current line to after the fifth line. For number 10 several people said 30|10x, but it deletes characters 30-39, and although it's picky, the problem was to delete THROUGH 40. Some people didn't seem to know about the HLM operators and had gruesome answers for #11. The concept of motion is covered fairly well in /usr/doc/ex/vi.apwh.ms. On number 14, my intention was for 'the word "the"' to mean the word and not the string, hence the \ operators should have been specified in the pattern string, e.g. /\$dd``., but only a couple of people used the word delimiters, so I took searches for the string "the" as being acceptable. It was pointed out that on number 15 the :se sw=12$>>9j doesn't account for unusual placement of blanks and tabs at the start of the line, but since most people didn't make provisions, I accepted :se sw=12... The real ringer was without a doubt number 18. Apparently many people didn't know about the tr command and those that did didn't know that arguments of the form 0-9 are as good as [0-9]. Several people pointed out that if a shell script x was present and contained "tr 0-9 1-90", then H!Lx would do the trick. One person used the y command of sed to translate the string. I suppose that a better question could have been made for 18, but in actuality, it worked out very well, most people used tr, although many had overweight argument lists. Although #19 involves the use of the undocumented ~ command, about half the people knew about the ~. Looking back ------------ I originally did an early version of this quiz at NCSU during a dull moment. My goal in creating it was to motivate people to learn more about Vi than just enough to get by. A number of people stated that they enjoyed the quiz and learned something from it, so I suppose my goal has been achieved. The test probably seemed trivial to many people, but I wanted something that could be done in a few minutes. Some of the things that I would have liked to mention but didn't: The map and map! commands, reading in a file with a ~ in the name, appending to a file. I would have also liked to include some more ed type stuff, but most of that can be found in the online ed quiz(6). I've also got a Csh quiz, but its not very well defined, and sending it out and trying to score the answers would be like grading a physics test whose sole question was: "State the laws of thermodynamics in your own words". Bill Mitchell Univ. of Central Florida ----------------------------------------------------------------- gopher://quux.org/ conversion by John Goerzen of http://communication.ucsd.edu/A-News/ This Usenet Oldnews Archive article may be copied and distributed freely, provided: 1. There is no money collected for the text(s) of the articles. 2. The following notice remains appended to each copy: The Usenet Oldnews Archive: Compilation Copyright (C) 1981, 1996 Bruce Jones, Henry Spencer, David Wiseman.