title: Count all possible computer programs of length N
body: <p>I will make this easy to understand using Javascript as language</p>
  
  <p>Using ascii as alphabet, and given all possible "statements" of length N formed using ascii, how many will be a valid JS program. Example for length 8</p>
  
  <pre><code>var i=0; //Is a string 8 characters long, and valid JS
  jar i=0; //Is a string 8 characters long, but invalid JS
  gfjsjhh3 //Is a string 8 characters long, but invalid JS
  now imagine we have all possible strings 8 characters long. 
  How many will be valid JS?
  </code></pre>
  
  <p>Further rules:</p>
  
  <p>1) variables are as short <em>as possible</em></p>
  
  <p>2) no blank spaces except where necessary </p>
  
  <p>More formal definition of problem:</p>
  
  <p>If we are given a grammar G for alphabet K, and also the collection of all possible combinations (statements) of length N that can be formed with K(or K* up to length N), how many of those statements will satisfy grammar G.</p>
  
  <p>I know you are thinking this is some academic, away from reality stuff. However, if the number of statements that are programs is much less than the total number of combinations, you could use small "numbers" to refer to locations where these sparse programs appear in the sea of combinations, and be able to send this "address" instead of the whole program, greatly reducing payload</p>