@@ -23,19 +23,20 @@ public int amoluntOfValidCellsAroundSlice(List<Cell> slice, List<Cell> pizza){
2323 //checking bottom cells.
2424 if (didPizzaContainsAllNeededHorizontalCells (pizza , differenceXCoordinates , maxY + 1 )) cellsAroundSlice += differenceXCoordinates .size ();
2525
26- //checking rirht cells.
26+ //checking right cells.
2727 if (didPizzaContainsAllNeededVerticalCells (pizza , differenceYCoordinates , minX - 1 )) cellsAroundSlice += differenceYCoordinates .size ();
2828
2929 return cellsAroundSlice ;
3030 }
3131
3232 public boolean stepUp (List <Cell > slice , List <Cell > pizza , int maxCellsInSlice ){
3333
34- // finding min y coordinate in slice and fill values to differenceXCoordinates .
34+ // finding min y coordinate in slice.
3535 Integer minYCoordInSlice = findMinY (slice );
36+ // find all difference x coordinates.
3637 List <Integer > differenceXCoordinates = fillAllDifferenceX (slice );
3738
38- //prevent this method for cutting too big slice.
39+ //prevent this method from cutting too big slice.
3940 if (slice .size () + differenceXCoordinates .size () > maxCellsInSlice ) return false ;
4041
4142 //our pizza still have all needed cells for this step? lets check it.
@@ -102,7 +103,7 @@ public boolean stepLeft(List<Cell> slice, List<Cell> pizza, int maxCellsInSlice)
102103
103104 if (slice .size () + differenceYCoordinates .size () > maxCellsInSlice ) return false ;
104105
105- boolean pizzaContainsAllNeededCells = didPizzaContainsAllNeededVerticalCells (pizza , differenceYCoordinates , minXCoordInSlice -1 1 );
106+ boolean pizzaContainsAllNeededCells = didPizzaContainsAllNeededVerticalCells (pizza , differenceYCoordinates , minXCoordInSlice -1 );
106107
107108 if (pizzaContainsAllNeededCells ){
108109 for (int yCoord : differenceYCoordinates ){
@@ -128,8 +129,8 @@ private List<Integer> fillAllDifferenceX(List<Cell> slice){
128129 private List <integer > fillAllDifferenceY (List <Cell > slice ){
129130 List <Integer > diffY = new ArrayList <Integer >();
130131 for (Cell cell : slice ){
131- if (!diffX .contains (cell .y )){
132- diffX .add (cell .y );
132+ if (!diffY .contains (cell .y )){
133+ diffY .add (cell .y );
133134 }
134135 }
135136 return diffY ;
@@ -201,10 +202,10 @@ private boolean didPizzaContainsAllNeededHorizontalCells(List<Cell> pizza, List<
201202 return returnValue ;
202203 }
203204
204- private boolean didPizzaContainsAllNeededVerticalCells (List <Cell > pizza , List <Integer > differenceYCoordinate , Integer minXCoordinate ){
205+ private boolean didPizzaContainsAllNeededVerticalCells (List <Cell > pizza , List <Integer > differenceYCoordinate , Integer xCoord ){
205206 boolean returnValue = true ;
206207 for (Integer yCoord : differenceYCoordinate ){
207- if (!pizza .contains (new Cell (minXCoordinate , yCoord ))){
208+ if (!pizza .contains (new Cell (xCoord , yCoord ))){
208209 returnValue = false ;
209210 }
210211 }
0 commit comments