Created
April 4, 2011 21:37
-
-
Save philippeantoine/902495 to your computer and use it in GitHub Desktop.
2011-04-04 codingdojo puissance4 randori
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package dojo.kata; | |
import java.util.List; | |
public class Puissance4 { | |
public Object solve(List<List<Integer>> grid) { | |
boolean cpt = false; | |
int r=0; | |
int c=0; | |
for (List<Integer> currentColumn : grid) { | |
for (Integer currentRow : currentColumn) { | |
if (currentRow != null) { | |
r+=currentRow; | |
} else if (currentColumn.size() == 1) { | |
if (currentColumn.get(0) == 1) { | |
c+=1; | |
} | |
} | |
} | |
} | |
if (r==3 || c==3) { | |
return 1; | |
} | |
return 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment