import java.util.Scanner; import java.io.File; import java.io.FileNotFoundException; public class programm { Scanner scan; Scanner scanOut; Scanner scanOut2; String last; String filename; int vCars; int hCars; char[] arr; char[] tmpArr; String tmpOutput; int steps; char tmpChar2; public static void main(String[] args) { if(args.length == 0) { new programm(); } else{ for (int i=0;i=2 ) { cl = true; } return cl; } public boolean canRight(int ppos) { boolean cr = false; if ( pposinput && tmpArr[i] == '0') { n++; } } if (n>0 && goRight(input) == true) { ccr = true; } if (n>=2 && goRight(input) == false) { ccr = true; } return ccr; } public boolean canCanLeft(int input) { boolean ccl = false; int n = 0; for(int i=0;i0 && goRight(input) == false) { ccl = true; } if (n>=2 && goRight(input) == true) { ccl = true; } return ccl; } public void moveRight(char car) { boolean found = false ; int t = 0; while (found == false) { if(tmpArr[t] == car) { if(tmpArr[t+2] != '0' && canRight(t+2) == true ) { moveRight(tmpArr[t+2]); } if (canRight(t) == false) { moveLeft(car); } tmpOutput += tmpArr[t]; tmpOutput += " Rechts "; tmpArr[t+2]=tmpArr[t]; tmpArr[t]='0'; found = true; } t++; } } public void moveLeft(char car) { boolean found = false ; int t = 0; while (found == false) { if(tmpArr[t] == car) { if(tmpArr[t-1] != '0' && canLeft(t+1)) { moveLeft(tmpArr[t-1]); } tmpOutput += tmpArr[t]; tmpOutput += " Links "; tmpArr[t-1]=tmpArr[t]; tmpArr[t+1]='0'; found = true; } t++; } } }