File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
src/main/java/com/google/hashcode/utils Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change 11package com .google .hashcode .utils ;
22
33import com .google .hashcode .entity .Cell ;
4+ import com .google .hashcode .entity .Ingredient ;
45import com .google .hashcode .entity .Pizza ;
56import com .google .hashcode .entity .Slice ;
67import com .google .hashcode .entity .Step ;
78import org .slf4j .Logger ;
89import org .slf4j .LoggerFactory ;
910
1011import java .util .ArrayList ;
12+ import java .util .Iterator ;
1113import java .util .List ;
1214import java .util .Optional ;
1315import java .util .stream .Collectors ;
@@ -76,7 +78,19 @@ Slice performStep(Pizza pizza, List<Step> steps) {
7678
7779 List <Slice > cutAllStartPositions (Pizza pizza ) {
7880 //TODO pick-ups a step with a minimal steps number, execute it(cut it from the pizza, and a slice). The pizza is a mutable object
79- return new ArrayList <>();
81+ List <Cell > currentPizza = pizza .getCells ();
82+ List <Slice > starts = new ArrayList <Slice >();
83+ Iterator <Cell > iter = currentPizza .iterator ();
84+ while (iter .hasNext ()){
85+ Cell cell = iter .next ();
86+ if (cell .ingredient == Ingredient .MUSHROOM ){
87+ Slice slice = new Slice ();
88+ slice .cells .add (cell );
89+ starts .add (slice );
90+ iter .remove ();
91+ }
92+ }
93+ return starts ;
8094 }
8195
8296}
You can’t perform that action at this time.
0 commit comments