title: Code Golf: Code 39 Bar Code
body: <h2>The challenge</h2>
  
  <p>The shortest code by character count to draw an ASCII representation of a Code 39 bar code.</p>
  
  <p>Wikipedia article about Code 39:   <a href="http://en.wikipedia.org/wiki/Code_39" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Code_39</a></p>
  
  <h2>Input</h2>
  
  <p>The input will be a string of legal characters for Code 39 bar codes. This means 43 characters are valid: <code>0</code>-<code>9</code> <code>A</code>-<code>Z</code> <code></code>(space) and <code>-.$/+%</code>. The <code>*</code> character will not appear in the input as it is used as the start and stop characters.</p>
  
  <h2>Output</h2>
  
  <p>Each character encoded in Code 39 bar codes have nine elements, five bars and four spaces. Bars will be represented with <code>#</code> characters, and spaces will be represented with the space character. Three of the nine elements will be wide. The narrow elements will be one character wide, and the wide elements will be three characters wide. A inter-character space of a single space should be added between each character pattern. The pattern should be repeated so that the height of the bar code is eight characters high.</p>
  
  <p>The start/stop character <code>*</code> (bWbwBwBwb) would be represented like this:</p>
  
  <pre><code>                       #   # ### ### # 
                         #   # ### ### # 
                         #   # ### ### # 
                         #   # ### ### # 
                         #   # ### ### # 
                         #   # ### ### # 
                         #   # ### ### # 
                         #   # ### ### # 
                         ^ ^ ^^ ^ ^ ^ ^^^
                         | | || | | | |||
             narrow bar -+ | || | | | |||
             wide space ---+ || | | | |||
             narrow bar -----+| | | | |||
           narrow space ------+ | | | |||
               wide bar --------+ | | |||
           narrow space ----------+ | |||
               wide bar ------------+ |||
           narrow space --------------+||
             narrow bar ---------------+|
  inter-character space ----------------+
  </code></pre>
  
  <ul>
  <li>The start and stop character <code>*</code> will need to be output at the start and end of the bar code.</li>
  <li>No quiet space will need to be included before or after the bar code.</li>
  <li>No check digit will need to be calculated.</li>
  <li>Full ASCII Code39 encoding is not required, just the standard 43 characters.</li>
  <li>No text needs to be printed below the ASCII bar code representation to identify the output contents.</li>
  <li>The character <code>#</code> can be replaced with another character of higher density if wanted. Using the full block character U+2588, would allow the bar code to actually scan when printed.</li>
  </ul>
  
  <h2>Test cases</h2>
  
  <pre><code>Input:
  ABC
  Output:
  #   # ### ### # ### # #   # ### # ### #   # ### ### ### #   # # #   # ### ### # 
  #   # ### ### # ### # #   # ### # ### #   # ### ### ### #   # # #   # ### ### # 
  #   # ### ### # ### # #   # ### # ### #   # ### ### ### #   # # #   # ### ### # 
  #   # ### ### # ### # #   # ### # ### #   # ### ### ### #   # # #   # ### ### # 
  #   # ### ### # ### # #   # ### # ### #   # ### ### ### #   # # #   # ### ### # 
  #   # ### ### # ### # #   # ### # ### #   # ### ### ### #   # # #   # ### ### # 
  #   # ### ### # ### # #   # ### # ### #   # ### ### ### #   # # #   # ### ### # 
  #   # ### ### # ### # #   # ### # ### #   # ### ### ### #   # # #   # ### ### # 
  </code></pre>
  
  <hr>
  
  <pre><code>Input:
  1/3
  Output:
  #   # ### ### # ### #   # # ### #   #   # #   # ### ###   # # # #   # ### ### # 
  #   # ### ### # ### #   # # ### #   #   # #   # ### ###   # # # #   # ### ### # 
  #   # ### ### # ### #   # # ### #   #   # #   # ### ###   # # # #   # ### ### # 
  #   # ### ### # ### #   # # ### #   #   # #   # ### ###   # # # #   # ### ### # 
  #   # ### ### # ### #   # # ### #   #   # #   # ### ###   # # # #   # ### ### # 
  #   # ### ### # ### #   # # ### #   #   # #   # ### ###   # # # #   # ### ### # 
  #   # ### ### # ### #   # # ### #   #   # #   # ### ###   # # # #   # ### ### # 
  #   # ### ### # ### #   # # ### #   #   # #   # ### ###   # # # #   # ### ### # 
  </code></pre>
  
  <hr>
  
  <pre><code>Input:
  - $     (minus space dollar)
  Output:
  #   # ### ### # #   # # ### ### #   ### # ### # #   #   #   # # #   # ### ### # 
  #   # ### ### # #   # # ### ### #   ### # ### # #   #   #   # # #   # ### ### # 
  #   # ### ### # #   # # ### ### #   ### # ### # #   #   #   # # #   # ### ### # 
  #   # ### ### # #   # # ### ### #   ### # ### # #   #   #   # # #   # ### ### # 
  #   # ### ### # #   # # ### ### #   ### # ### # #   #   #   # # #   # ### ### # 
  #   # ### ### # #   # # ### ### #   ### # ### # #   #   #   # # #   # ### ### # 
  #   # ### ### # #   # # ### ### #   ### # ### # #   #   #   # # #   # ### ### # 
  #   # ### ### # #   # # ### ### #   ### # ### # #   #   #   # # #   # ### ### # 
  </code></pre>
  
  <p>Code count includes input/output (full program).</p>