package com.codegym.task.task10.task1012;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
/*
Number of letters
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
// Alphabet
String abc = "abcdefghijklmnopqrstuvwxyz";
char[] abcArray = abc.toCharArray();
ArrayList<Character> alphabet = new ArrayList<>();
for (char letter : abcArray) {
alphabet.add(letter);
}
// Read in strings
ArrayList<String> list = new ArrayList<>();
for (int i = 0; i < 10; i++) {
String s = reader.readLine();
list.add(s.toLowerCase());
}
// write your code here
ArrayList<Integer> anotherList = new ArrayList<Integer>();
HashMap<Character, Integer> map = new HashMap<Character, Integer>();
int count = 0;
String newString = null;
for (String s : list) {
newString += s;
}
assert newString != null;
char[] anotherArray = newString.toCharArray();
for (char c : abcArray) {
for (char value : anotherArray) {
if (c == value) {
count++;
}
}
anotherList.add(count);
count = 0;
}
for(int i = 0; i < abcArray.length; i++){
map.put(abcArray[i], anotherList.get(i));
}
for (Map.Entry<Character, Integer> set : map.entrySet()){
System.out.println(set.getKey() + " " + set.getValue());
}
// for(int i = 0; i < anotherList.size(); i++){
// System.out.println(abcArray[i]+" "+anotherList.get(i));
// }
}
}
package com.codegym.task.task10.task1012;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
/*
Number of letters
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
// Alphabet
String abc = "abcdefghijklmnopqrstuvwxyz";
char[] abcArray = abc.toCharArray();
ArrayList<Character> alphabet = new ArrayList<>();
for (char letter : abcArray) {
alphabet.add(letter);
}
// Read in strings
ArrayList<String> list = new ArrayList<>();
for (int i = 0; i < 10; i++) {
String s = reader.readLine();
list.add(s.toLowerCase());
}
// write your code here
ArrayList<Integer> anotherList = new ArrayList<Integer>();
HashMap<Character, Integer> map = new HashMap<Character, Integer>();
int count = 0;
String newString = null;
for (String s : list) {
newString += s;
}
assert newString != null;
char[] anotherArray = newString.toCharArray();
for (char c : abcArray) {
for (char value : anotherArray) {
if (c == value) {
count++;
}
}
anotherList.add(count);
count = 0;
}
for(int i = 0; i < abcArray.length; i++){
map.put(abcArray[i], anotherList.get(i));
}
for (Map.Entry<Character, Integer> set : map.entrySet()){
System.out.println(set.getKey() + " " + set.getValue());
}
// for(int i = 0; i < anotherList.size(); i++){
// System.out.println(abcArray[i]+" "+anotherList.get(i));
// }
}
}