Last active
December 16, 2015 17:18
-
-
Save lgo/5469043 to your computer and use it in GitHub Desktop.
ECOO Cryptarithm Encrypter
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.BufferedReader; | |
| import java.io.BufferedWriter; | |
| import java.io.FileReader; | |
| import java.io.FileWriter; | |
| import java.util.ArrayList; | |
| import java.util.HashMap; | |
| import java.util.List; | |
| import java.util.Map; | |
| public class Sol4 { | |
| public static void main(String[] args) throws Exception { | |
| BufferedReader br = new BufferedReader(new FileReader("in4.txt")); | |
| BufferedWriter bw = new BufferedWriter(new FileWriter("out4.txt")); | |
| for (int sets = 0; sets < 5; sets++) { | |
| Map<Character, Integer> value = new HashMap<Character, Integer>(); | |
| ArrayList<Integer>[] sum = new ArrayList[3]; | |
| String[] set = new String[3]; | |
| for (ArrayList<Integer> s : sum) { | |
| s = new ArrayList<Integer>(0); | |
| } | |
| for (int i = 0; i < 5; i++) { | |
| for (int j = 0; j < 3; j++) { | |
| set[j] = br.readLine(); | |
| } | |
| value.put(set[2].charAt(0), 1); | |
| insert(sum[3], 0, 1); | |
| } | |
| for (int i = 0; i < 3; i++) { | |
| int total = 0; | |
| for (int num : sum[i]) { | |
| total += num; | |
| } | |
| System.out.println(set[i] + "\t" + total); | |
| } | |
| } | |
| } | |
| public static void insert(ArrayList<Integer> sum, int index, int value) { | |
| sum.add(index, value); | |
| sum.remove(index + 1); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment