Program: 13912
Project: 13912
Buggy source:
public GameField generateSolvedField(int width,int height){
  GameField gameField=new GameField();
  int startX;
  int startY;
  int direction;
  tiles=new Tile[width][height];
  for (int i=1; i < width - 1; i++) {
    for (int j=1; j < height - 1; j++) {
      tiles[i][j]=new Tile(false,false,false,false,UNDEFINED,'o');
    }
  }
  for (int i=0; i < width; i++) {
    tiles[i][0]=new Tile(false,false,false,false,TileType.NONE,'n');
  }
  for (int i=0; i < width; i++) {
    tiles[i][height - 1]=new Tile(false,false,false,false,TileType.NONE,'n');
  }
  for (int i=0; i < height; i++) {
    tiles[0][i]=new Tile(false,false,false,false,TileType.NONE,'n');
  }
  for (int i=0; i < height; i++) {
    tiles[width - 1][i]=new Tile(false,false,false,false,TileType.NONE,'n');
  }
  Tile startTile;
switch ((int)(Math.random() * (4))) {
case 0:
    startTile=new Tile(false,true,false,false,TileType.START,'s');
  startX=(int)(Math.random() * (width - 2) + 1);
startY=0;
direction=0;
tiles[startX][0]=startTile;
break;
case 1:
startTile=new Tile(true,false,false,false,TileType.START,'s');
startX=(int)(Math.random() * (width - 2) + 1);
startY=height - 1;
direction=2;
tiles[startX][height - 1]=startTile;
break;
case 2:
startTile=new Tile(false,false,false,true,TileType.START,'s');
startX=0;
startY=(int)(Math.random() * (height - 2) + 1);
direction=1;
tiles[startX][startY]=startTile;
break;
case 3:
startTile=new Tile(false,false,true,false,TileType.START,'s');
startX=width - 1;
startY=(int)(Math.random() * (height - 2) + 1);
direction=3;
tiles[startX][startY]=startTile;
break;
default :
throw new IllegalStateException("String_Node_Str");
}
int x=startX;
int y=startY;
while ((x != 0 && x != width - 1 && y != 0 && y != height - 1) || (x == startX && y == startY)) {
if (Math.random() < 0.7f && !(startX == x && startY == y)) {
direction=(int)(Math.random() * 4);
}
int xNew=x + directionsX[direction];
int yNew=y + directionsY[direction];
while (tiles[xNew][yNew].getTileType() != UNDEFINED && tiles[xNew][yNew].getShortcut() != 'n') {
direction=(int)(Math.random() * (4) + 0);
xNew=x + directionsX[direction];
yNew=y + directionsY[direction];
}
switch (direction) {
case 0:
tiles[x][y].setBottom(true);
tiles[xNew][yNew].setTop(true);
break;
case 1:
tiles[x][y].setRight(true);
tiles[xNew][yNew].setLeft(true);
break;
case 2:
tiles[x][y].setTop(true);
tiles[xNew][yNew].setBottom(true);
break;
case 3:
tiles[x][y].setLeft(true);
tiles[xNew][yNew].setRight(true);
break;
default :
throw new IllegalStateException("String_Node_Str");
}
x=xNew;
y=yNew;
tiles[x][y].setTileType(TileType.PUZZLE);
}
for (int i=1; i < width - 1; i++) {
for (int j=1; j < height - 1; j++) {
tiles[i][j].setTileType(PUZZLE);
tiles[i][j].setShortcut(tileShortcutHashMap.get(tiles[i][j]));
}
}
tiles[x][y].setTileType(TileType.FINISH);
tiles[x][y].setShortcut('f');
gameField.setStartX(startX);
gameField.setStartY(startY);
gameField.setField(tiles);
return gameField;
}

Fixed version (ground truth):
public GameField generateSolvedField(int width,int height){
  int number=0;
  GameField gameField=new GameField();
  int startX;
  int startY;
  int direction;
  tiles=new Tile[width][height];
  for (int i=1; i < width - 1; i++) {
    for (int j=1; j < height - 1; j++) {
      tiles[i][j]=new Tile(false,false,false,false,UNDEFINED,'o');
    }
  }
  for (int i=0; i < width; i++) {
    tiles[i][0]=new Tile(false,false,false,false,TileType.NONE,'n');
  }
  for (int i=0; i < width; i++) {
    tiles[i][height - 1]=new Tile(false,false,false,false,TileType.NONE,'n');
  }
  for (int i=0; i < height; i++) {
    tiles[0][i]=new Tile(false,false,false,false,TileType.NONE,'n');
  }
  for (int i=0; i < height; i++) {
    tiles[width - 1][i]=new Tile(false,false,false,false,TileType.NONE,'n');
  }
  Tile startTile;
switch ((int)(Math.random() * (4))) {
case 0:
    startTile=new Tile(false,true,false,false,TileType.START,'s');
  startX=(int)(Math.random() * (width - 2) + 1);
startY=0;
direction=0;
tiles[startX][0]=startTile;
break;
case 1:
startTile=new Tile(true,false,false,false,TileType.START,'s');
startX=(int)(Math.random() * (width - 2) + 1);
startY=height - 1;
direction=2;
tiles[startX][height - 1]=startTile;
break;
case 2:
startTile=new Tile(false,false,false,true,TileType.START,'s');
startX=0;
startY=(int)(Math.random() * (height - 2) + 1);
direction=1;
tiles[startX][startY]=startTile;
break;
case 3:
startTile=new Tile(false,false,true,false,TileType.START,'s');
startX=width - 1;
startY=(int)(Math.random() * (height - 2) + 1);
direction=3;
tiles[startX][startY]=startTile;
break;
default :
throw new IllegalStateException("String_Node_Str");
}
int x=startX;
int y=startY;
while ((x != 0 && x != width - 1 && y != 0 && y != height - 1) || (x == startX && y == startY)) {
number++;
if (Math.random() < 0.7f && !(startX == x && startY == y)) {
direction=(int)(Math.random() * 4);
}
int xNew=x + directionsX[direction];
int yNew=y + directionsY[direction];
boolean directions[]=new boolean[]{false,false,false,false};
while (tiles[xNew][yNew].getTileType() != UNDEFINED && tiles[xNew][yNew].getShortcut() != 'n') {
if (directions[0] && directions[1] && directions[2]&& directions[3]) {
return generateSolvedField(width,height);
}
directions[direction]=true;
direction=(int)(Math.random() * (4) + 0);
xNew=x + directionsX[direction];
yNew=y + directionsY[direction];
}
switch (direction) {
case 0:
tiles[x][y].setBottom(true);
tiles[xNew][yNew].setTop(true);
break;
case 1:
tiles[x][y].setRight(true);
tiles[xNew][yNew].setLeft(true);
break;
case 2:
tiles[x][y].setTop(true);
tiles[xNew][yNew].setBottom(true);
break;
case 3:
tiles[x][y].setLeft(true);
tiles[xNew][yNew].setRight(true);
break;
default :
throw new IllegalStateException("String_Node_Str");
}
x=xNew;
y=yNew;
tiles[x][y].setTileType(TileType.PUZZLE);
}
for (int i=1; i < width - 1; i++) {
for (int j=1; j < height - 1; j++) {
tiles[i][j].setTileType(PUZZLE);
tiles[i][j].setShortcut(tileShortcutHashMap.get(tiles[i][j]));
}
}
tiles[x][y].setTileType(TileType.FINISH);
tiles[x][y].setShortcut('f');
gameField.setStartX(startX);
gameField.setStartY(startY);
gameField.setField(tiles);
if (number > (width - 2) * (height - 2) / 3) {
return gameField;
}
 else {
return generateSolvedField(width,height);
}
}