title: Adding one digit (0-9) to the sequence/string creates new 4 digits number
body: <p>I'm trying to find an algorithm which "breaks the safe" by typing the keys 0-9. The code is 4 digits long. The safe will be open where it identifies the code as substring of the typing. meaning, if the code is "3456" so the next typing will open the safe: "123456". (It just means that the safe is not restarting every 4 keys input).</p>
  
  <p>Is there an algorithm which every time it add one digit to the sequence, it creates new 4 digits number (new combinations of the last 4 digits of the sequence\string)?</p>
  
  <p>thanks, km.</p>
  
  <p>Editing (I post it years ago):
  The question is how to make sure that every time I set an input (one digit) to the safe, I generate a new 4 digit code that was not generated before. For example, if the safe gets binary code with 3 digits long then this should be my input sequence:</p>
  
  <pre><code>0001011100 
  </code></pre>
  
  <p>Because for every input I get a new code (3 digit long) that was not generated before:</p>
  
  <pre><code>000 -&gt; 000
  1 -&gt; 001
  0 -&gt; 010
  1 -&gt; 101
  1 -&gt; 011
  1 -&gt; 111
  0 -&gt; 110
  0 -&gt; 100
  </code></pre>