title: Code Golf: Four is magic
body: <h3>The puzzle</h3>
  
  <p>A little puzzle I heard while I was in high school went something like this...</p>
  
  <ul>
  <li>The questioner would ask me to give him a number;</li>
  <li>On hearing the number, the questioner would do some sort of transformation on it repeatedly (for example, he might say <i>ten is three</i>) until eventually arriving at the number 4 (at which point he would finish with <i>four is magic</i>).</li>
  <li>Any number seems to be transformable into four eventually, no matter what.</li>
  </ul>
  
  <p>The goal was to try to figure out the transformation function and then be able to reliably proctor this puzzle yourself.</p>
  
  <h3>The solution</h3>
  
  <p>The transformation function at any step was to</p>
  
  <ul>
  <li>Take the number in question,</li>
  <li>Count the number of letters in its English word representation, ignoring a hyphen or spaces or "and" (e.g., "ten" has 3 letters in it, "thirty-four" has 10 letters in it, "one hundred forty-three" has 20 letters in it).</li>
  <li>Return that number of letters.</li>
  </ul>
  
  <p>For all of the numbers I have ever cared to test, this converges to 4. Since "four" also has four letters in it, there would be an infinite loop here; instead it is merely referred to as <i>magic</i> by convention to end the sequence.</p>
  
  <h3>The challenge</h3>
  
  <p>Your challenge is to create a piece of code that will read a number from the user and then print lines showing the transformation function being repeatedly applied until "four is magic" is reached.</p>
  
  <p>Specifically:</p>
  
  <ol>
  <li>Solutions must be complete programs in and of themselves. They cannot merely be functions which take in a number-- factor in the input.</li>
  <li>Input must be read from standard input. (Piping from "echo" or using input redirection is fine since that also goes from stdin)</li>
  <li>The input should be in numeric form.</li>
  <li>For every application of the transformation function, a line should be printed: <code>a is b.</code>, where a and b are numeric forms of the numbers in the transformation.</li>
  <li>Full stops (periods) ARE required!</li>
  <li>The last line should naturally say, <code>4 is magic.</code>.</li>
  <li>The code should produce correct output for all numbers from <b>0 to 99</b>.</li>
  </ol>
  
  <p>Examples:</p>
  
  <pre><code>&gt; 4
  4 is magic.
  
  &gt; 12
  12 is 6.
  6 is 3.
  3 is 5.
  5 is 4.
  4 is magic.
  
  &gt; 42
  42 is 8.
  8 is 5.
  5 is 4.
  4 is magic.
  
  &gt; 0
  0 is 4.
  4 is magic.
  
  &gt; 99
  99 is 10.
  10 is 3.
  3 is 5.
  5 is 4.
  4 is magic.
  </code></pre>
  
  <p>The winner is the <b>shortest submission by source code character count</b> which is also <b>correct</b>.</p>
  
  <h3>BONUS</h3>
  
  <p>You may also try to write a version of the code which prints out the ENGLISH NAMES for the numbers with each application of the transformation function. The original input is still numeric, but the output lines should have the word form of the number.</p>
  
  <p><a href="https://stackoverflow.com/questions/3230978/code-golf-four-is-magic/3241200#3241200">(Double bonus for drawing shapes with your code)</a></p>
  
  <p><b>(EDIT)</b> Some clarifications:</p>
  
  <ol>
  <li>I do want the word to appear on both sides in all applicable cases, e.g. <code>Nine is four. Four is magic.</code></li>
  <li>I don't care about capitalization, though. And I don't care how you separate the word tokens, though they should be separated: <code>ninety-nine</code> is okay, <code>ninety nine</code> is okay, <code>ninetynine</code> is not okay.</li>
  </ol>
  
  <p>I'm considering these a separate category for bonus competition with regard to the challenge, so if you go for this, don't worry about your code being longer than the numeric version.</p>
  
  <p>Feel free to submit one solution for each version.</p>