// package whatever; // don't place package name!

import java.io.*;
import java.util.ArrayList;

class myCode
{
    public static class Stand {
        int ringPos;
        int keyPos;
        int length;
        
        Stand(int ringPos, int keyPos, int length) {
            this.ringPos = ringPos;
            this.keyPos = keyPos;
            this.length = length;
        }
        
        int getRingPos() {
            return this.ringPos;
        }
        
        int getKeyPos() {
            return this.keyPos;
        }
        
        int getLength() {
            return this.length;
        }
    }
    
    public static class StandList extends ArrayList<Stand> {};
    
    public static void main (String[] args) throws java.lang.Exception
    {
        System.out.println("Hello Java");
        int count = findRotateSteps(
            "caotmcaataijjxi", 
            "oatjiioicitatajtijciocjcaaxaaatmctxamacaamjjx");
        System.out.println(count);

    }

    public static int findRotateSteps(String ring, String key) {
        StandList[][] path = new StandList[100][100];
        for (int span = 0; span < key xss=removed xss=removed xss=removed xss=removed path[%s][%s]=(%s,%s,%s) xss=removed xss=removed xss=removed xss=removed xss=removed xss=removed xss=removed> initStands = path[keyPos][oldSpan];
            int midKeyPos = initStands.get(0).getKeyPos();
            int midRingPos = initStands.get(0).getRingPos();
            ArrayList<Stand> nextStands = path[midKeyPos][nextSpan];
            int newLen =
                initStands.get(0).getLength() +
                nextStands.get(0).getLength();
            if (minStands.isEmpty() || newLen < minStands.get(0).getLength()) {
                minStands.clear();
                minStands.add(
                    new Stand(
                        nextStands.get(0).getRingPos(), 
                        nextStands.get(0).getKeyPos(), 
                        newLen));
            }
        }
        return minStands;
    }
    
    
    public static StandList findStands(
        String ring, String key, int ringPos, int keyPos) {
        StandList stands = new StandList();
        int rightRingPos = ringPos;
        int leftRingPos = ringPos;
        int stepCount = 0;
        while (key.charAt(keyPos) != ring.charAt(rightRingPos) &&
            key.charAt(keyPos) != ring.charAt(leftRingPos)) {
            if (rightRingPos == ring.length() - 1) {
                rightRingPos = 0;
            } else {
                rightRingPos++;
            }
            if (leftRingPos == 0) {
                leftRingPos = ring.length() - 1;
            } else {
                leftRingPos--;
            }
            stepCount++;
        }
        if (key.charAt(keyPos) == ring.charAt(rightRingPos)) {
            stands.add(new Stand(rightRingPos, keyPos, stepCount));
        }
        if (key.charAt(keyPos) == ring.charAt(leftRingPos)) {
            stands.add(new Stand(leftRingPos, keyPos, stepCount));
        }
        return stands;
    }

}

Add a code snippet to your website: www.paste.org