title: Text Pyramid using recursion in Java
body: <p>I am trying to make a full triangle with any text input. Example if I have string that is "abcdefghij" I want the result to be </p>
  
  <pre><code>    aj
     abij
    abchij
   abcdghij
  abcdefghij
  </code></pre>
  
  <p>if the string length is odd as in "abcdefghij" then the output would be</p>
  
  <pre><code>    a
     abi
    abchi
   abcdghi
  abcdefghi
  </code></pre>
  
  <p>Here is what I have so far but my output for the words is upside down. My output is</p>
  
  <pre><code>    abcdefghij
     abcdghij
    abchij
   abij
  aj
  </code></pre>
  
  <p><strong>What I have done so far</strong></p>
  
  <pre><code>public static void main(String[] args) {
  
          solve("abcdefghij");
  
      }
  
      public static void solve(String word) {
  
          solve(word, word.length()/2-1);
  
      }
  
      public static void solve(String word, int it) {
  
          // print starting spaces
          for(int i = 0; i &lt; it; i++)
              System.out.print(" ");
  
          // print out string
          System.out.print(word+"\n");
  
  
          if(word.length() &gt; 2) {
  
              int newlengthperside = (word.length() - 2)/2;
              solve( word.substring(0, newlengthperside) + word.substring(word.length() - newlengthperside), it-1);
  
          }
      }
  </code></pre>
  
  <p>I just need a suggestion on how to start from aj instead of the end. Thanks for any help. <strong>This is homework so just a hint is appreciated.</strong></p>