Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class Puppy {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String word1 = scanner.nextLine();
- String word2 = scanner.nextLine();
- String newWord = "";
- int length = Math.min(word1.length(), word2.length());
- int differenceBetweenSizes = Math.abs(word1.length() - word2.length());
- for (int i = 0; i < length; i++) {
- int x = word1.charAt(i) - 'a';
- int y = word2.charAt(i) - 'a';
- if (x == -65 || y == -65) {
- newWord += " ";
- continue;
- }
- int result = Math.abs(x - y) + 'a';
- char join = (char) result;
- newWord += join;
- }
- for (int i = differenceBetweenSizes; i > 0; i--) {
- if (word1.length() < word2.length()) {
- newWord += word2.charAt(word2.length() - i);
- }
- }
- System.out.println(newWord);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement