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.HashSet; | |
| import java.util.Set; | |
| public class CandyShop { | |
| public int countProbablePlaces(int[] X, int[] Y, int[] R) { | |
| Set<Position> pos = new HashSet<Position>(); | |
| pos.add(new Position(X[0], Y[0])); | |
| pos = locationsFor(R[0], pos); | |
| for (int i = 1; i < X.length; i++) { |
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.HashMap; | |
| import java.util.HashSet; | |
| import java.util.Map; | |
| import java.util.Set; | |
| public class CubeStickers { | |
| public String isPossible(String[] sticker) { | |
| Set<String> uniqueStickers = new HashSet<String>(); | |
| for (String s : sticker) uniqueStickers.add(s); | |
| if (uniqueStickers.size() >= 5) return "YES"; |
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; |
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.Arrays; | |
| import java.util.HashSet; | |
| import java.util.Set; | |
| public class TheNumbersWithLuckyLastDigit { | |
| private static int INF = 9999; | |
| public int find(int n) { | |
| int[][] edges = new int[10][10]; | |
| for (int i = 0; i < edges.length; i++) |
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
| object Magicka { | |
| def invokeElements(spells: String, combines: List[String], oppositions: List[String]) = { | |
| val oppositionSets = oppositions.map(_.toSet) | |
| val combineMap = combines.map(c => (Set(c.charAt(0),c.charAt(1)), c.charAt(2))).toMap | |
| spells.map(List(_)).foldLeft(List[Char]())((acc,spell) => { | |
| acc.size match { | |
| case 0 => spell | |
| case _ => { | |
| // Lazily compute the set which represents spells in the accumulator that clash with the current spell. | |
| lazy val clashes = oppositionSets.filter(_.contains(spell.head)).map(_.diff(Set(spell.head))).flatten |
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.Arrays; | |
| import java.util.LinkedList; | |
| import java.util.Queue; | |
| public class PaintBucket { | |
| public static void main(String[] args) { | |
| int[][] colors = new int[][] {{2,2,0,1}, | |
| {1,0,0,0}, | |
| {0,0,0,1}, | |
| {1,1,1,1}}; |
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.io.File; | |
| import java.io.FileNotFoundException; | |
| import java.util.ArrayList; | |
| import java.util.Arrays; | |
| import java.util.List; | |
| import java.util.Scanner; | |
| public class CandySplitting { | |
| public static void main(String[] args) throws FileNotFoundException { | |
| Scanner sc = new Scanner(new File("C-small-attempt0.in")); |
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.io.File; | |
| import java.io.FileNotFoundException; | |
| import java.util.ArrayList; | |
| import java.util.HashMap; | |
| import java.util.HashSet; | |
| import java.util.List; | |
| import java.util.Map; | |
| import java.util.Scanner; | |
| import java.util.Set; |
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.io.File; | |
| import java.io.FileNotFoundException; | |
| import java.util.Queue; | |
| import java.util.Scanner; | |
| import java.util.concurrent.LinkedBlockingQueue; | |
| public class BotTrust { | |
| public static void main(String[] args) throws FileNotFoundException { | |
| Scanner sc = new Scanner(new File("A-large.in")); |
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
| public class PerfectSequences { | |
| public String fixIt(int[] seq) { | |
| if (seq.length == 1) return "Yes"; | |
| else { | |
| for(int i=0; i<seq.length; i++) { | |
| int sum = sum(seq,i); | |
| int product = product(seq,i); | |
| if (product == 0) continue; | |
| else { |