Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.sve;
- import java.util.Arrays;
- import java.util.Scanner;
- public class Playground {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- char[] inputLineChars = scan.nextLine().toCharArray();
- for (int i = 0; i < inputLineChars.length; ) {
- if (inputLineChars[i] == '|') {
- int startIndex = i;
- int bombLength = 1;
- int bombSum = 0;
- i++;
- while (inputLineChars[i] != '|') {
- bombSum += (int)inputLineChars[i];
- i++;
- bombLength++;
- }
- bombLength++;
- int lastDigit = bombSum % 10;
- int startOfDots = 0;
- int endOfDots = inputLineChars.length;
- if (startIndex - lastDigit >= 0) {
- startOfDots = startIndex - lastDigit;
- }
- if ((startIndex - lastDigit) + (lastDigit + bombLength) + lastDigit < inputLineChars.length) {
- endOfDots = (startIndex - lastDigit) + (lastDigit + bombLength) + lastDigit;
- }
- for (int j = startOfDots; j < endOfDots; j++) {
- inputLineChars[j] = '.';
- }
- }
- i++;
- }
- System.out.println(Arrays.toString(inputLineChars).replace("[", "").replace(", ", "").replace("]", ""));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment