import java.util.ArrayList; import java.util.List; public class Animation { public static void main(String s[]) { int speeds[] = {2,3,2,10,1,1,2}; String inits[] = {"..R....","RR..LRL","LRLR.LRLR","RLRLRLRLRL","...","LRRL.LR.LRR.R.LRRL.","..R.L.."}; for(int i = 0; i < speeds.length; i++) { Animation a = new Animation(); String[] result = a.animate(speeds[i], inits[i]); for(String r : result) System.out.println(r); System.out.println(); } } public String[] animate(int speed, String init) { int curr[] = new int[init.length()]; List result = new ArrayList(); boolean empty = false; for(int i = 0; i='R' && i+speed'R') && i-speed>=0) next[i-speed]+='L'; } result.add(state.toString()); curr = next; } return result.toArray(new String[0]); } }