Created
May 29, 2011 21:35
-
-
Save stphung/998153 to your computer and use it in GitHub Desktop.
TopCoder SRM 507 Division 2 - 250 point problem
This file contains hidden or 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
| import java.util.ArrayList; | |
| import java.util.List; | |
| public class CubeAnts { | |
| public int getMinimumSteps(int[] pos) { | |
| List<Integer> l = new ArrayList<Integer>(); | |
| for (int i : pos) l.add(i); | |
| if (l.contains(6)) return 3; | |
| else if (l.contains(2) || l.contains(5) || l.contains(7)) return 2; | |
| else if (l.contains(3) || l.contains(1) || l.contains(4)) return 1; | |
| return 0; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment