Note that there are some explanatory texts on larger screens.

plurals
  1. POFile Fix-it codegolf (GCJ 2010 1B-A)
    primarykey
    data
    text
    <p>Last year (2009), the <a href="http://code.google.com/codejam" rel="nofollow noreferrer">Google Code Jam</a> featured an interesting problem as the first problem in Round 1B: <a href="http://code.google.com/codejam/contest/dashboard?c=186264#" rel="nofollow noreferrer">Decision Tree</a></p> <p>As the problem seemed tailored for Lisp-like languages, we spontaneously had an <a href="https://stackoverflow.com/questions/1433263/decision-tree-code-golf">exciting codegolf</a> here on SO, in which a few languages managed to solve the problem in fewer characters than any Lisp variety, using quite a number of different techniques.</p> <p>This year's Round 1B Problem A (<a href="http://code.google.com/codejam/contest/dashboard?c=635101#" rel="nofollow noreferrer">File Fix-it</a>) also seems tailored for a particular family of languages, Unix shell scripts. So continuing the "1B-A tradition" would be appropriate. :p But which language will end up with the shortest code? Let us codegolf and see!</p> <p><strong>Problem description</strong> (adapted from official page):</p> <p>You are given <strong>T</strong> test cases. Each test case contains <strong>N</strong> lines that list the full path of <strong>all</strong> directories currently existing on your computer. For example:</p> <pre><code>/home /home/awesome /home/awesome/wheeeeeee /home/awesome/wheeeeeee/codegolfrocks /home/thecakeisalie </code></pre> <p>Next, you are given <strong>M</strong> lines that list the full path of directories you would like to create. They are in the same format as the previous examples. You can create a directory using the <code>mkdir</code> command, but you can only do so if the parent directory already exists. For example, to create the directories <code>/pyonpyon/fumufumu/yeahyeah</code> and <code>/pyonpyon/fumufumu/yeahyeahyeah</code>, you would need to use <code>mkdir</code> four times:</p> <pre><code>mkdir /pyonpyon mkdir /pyonpyon/fumufumu mkdir /pyonpyon/fumufumu/yeahyeah mkdir /pyonpyon/fumufumu/yeahyeahyeah </code></pre> <p>For each test case, return the number of times you have to call <code>mkdir</code> to create all the directories you would like to create.</p> <p><strong>Input</strong></p> <p>Input consists of a text file whose first line contains the integer <strong>T</strong>, the number of test cases. The rest of the file contains the test cases.</p> <p>Each test case begins with a line containing the integers <strong>N</strong> and <strong>M</strong>, separated by a space.</p> <p>The next <strong>N</strong> lines contain the path of each directory currently existing on your computer (not including the root directory <code>/</code>). This is a concatenation of one or more non-empty lowercase alphanumeric strings, each preceded by a single <code>/</code>.</p> <p>The following <strong>M</strong> lines contain the path of each directory you would like to create.</p> <p><strong>Output</strong></p> <p>For each case, print one line containing <code>Case #X: Y</code>, where <code>X</code> is the case number and <code>Y</code> is the solution.</p> <p><strong>Limits</strong></p> <p>1 ≤ T ≤ 100.</p> <p>0 ≤ N ≤ 100.</p> <p>1 ≤ M ≤ 100.</p> <p>Each path contains at most 100 characters.</p> <p>Every path appears only once in the list of directories already on your computer, or in the list of desired directories. However, a path may appear on both lists, as in example case #3 below.</p> <p>If a directory is in the list of directories already on your computer, its parent directory will also be listed, with the exception of the root directory <code>/</code>.</p> <p>The input file is at most 100,000 bytes long.</p> <p><strong>Example</strong></p> <p>Larger sample test cases may be downloaded <a href="http://code.google.com/codejam/contest/dashboard?c=635101#" rel="nofollow noreferrer">here</a>.</p> <p>Input:</p> <pre><code>3 0 2 /home/sparkle/pyon /home/sparkle/cakes 1 3 /z /z/y /z/x /y/y 2 1 /moo /moo/wheeeee /moo </code></pre> <p>Output:</p> <pre><code>Case #1: 4 Case #2: 4 Case #3: 0 </code></pre> <p><strong>Code Golf</strong></p> <p>Please post your shortest code in any language that solves this problem. Input and output may be handled via stdin and stdout or by other files of your choice. <strong>Please include a disclaimer if your code has the potential to modify or delete existing files when executed.</strong></p> <p>Winner will be the shortest solution (by byte count) in a language with an implementation existing prior to the start of Round 1B 2010. So while you are free to use a language you've just made up in order to submit a 0-byte solution, it won't count, and you'll probably get downvotes. ^_^</p> <p><strong>Standings</strong></p> <ul> <li>65 <a href="https://stackoverflow.com/questions/2892126/file-fix-it-codegolf-gcj-2010-1b-a/2892203#2892203">GolfScript</a></li> <li>100 <a href="https://stackoverflow.com/questions/2892126/file-fix-it-codegolf-gcj-2010-1b-a/2894170#2894170">Perl</a></li> <li>121 <a href="https://stackoverflow.com/questions/2892126/file-fix-it-codegolf-gcj-2010-1b-a/2896292#2896292">AWK</a> (not including interpreter options)</li> <li>128 <a href="https://stackoverflow.com/questions/2892126/file-fix-it-codegolf-gcj-2010-1b-a/2892132#2892132">Bash</a></li> <li>144 <a href="https://stackoverflow.com/questions/2892126/file-fix-it-codegolf-gcj-2010-1b-a/2893509#2893509">Ruby</a></li> <li>145 <a href="https://stackoverflow.com/questions/2892126/file-fix-it-codegolf-gcj-2010-1b-a/2892339#2892339">Python</a></li> <li>158 <a href="https://stackoverflow.com/questions/2892126/file-fix-it-codegolf-gcj-2010-1b-a/2893727#2893727">PyonScript</a></li> <li>159 <a href="https://stackoverflow.com/questions/2892126/file-fix-it-codegolf-gcj-2010-1b-a/2903039#2903039">J</a></li> <li>172 <a href="https://stackoverflow.com/questions/2892126/file-fix-it-codegolf-gcj-2010-1b-a/2893085#2893085">Lua</a></li> <li>182 <a href="https://stackoverflow.com/questions/2892126/file-fix-it-codegolf-gcj-2010-1b-a/2892613#2892613">PostScript</a></li> <li>189 <a href="https://stackoverflow.com/questions/2892126/file-fix-it-codegolf-gcj-2010-1b-a/2897631#2897631">Scala</a></li> <li>218 <a href="https://stackoverflow.com/questions/2892126/file-fix-it-codegolf-gcj-2010-1b-a/2893982#2893982">Haskell</a></li> <li>284 <a href="https://stackoverflow.com/questions/2892126/file-fix-it-codegolf-gcj-2010-1b-a/2892588#2892588">Java</a></li> <li>398 <a href="https://stackoverflow.com/questions/2892126/file-fix-it-codegolf-gcj-2010-1b-a/2892522#2892522">C#</a></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload