Advertisement
mirozspace

KFactory

Feb 7th, 2019
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.29 KB | None | 0 0
  1. import java.util.Arrays;
  2. import java.util.Scanner;
  3.  
  4. public class Pr10KaminoFactory {
  5.     public static void main(String[] args) {
  6.         Scanner scanner = new Scanner(System.in);
  7.  
  8.         int seqCounter = 0;
  9.         int seqLength = 0;
  10.         int seqSum = 0;
  11.         int seqFirstPosition = 0;
  12.  
  13.         while (true) {
  14.             String inputLineArray = scanner.nextLine();
  15.             if ("Clone them!".equals(inputLineArray)) {
  16.                 break;
  17.             }
  18.             int[] sequenceDNA = Arrays.stream(inputLineArray.split("!"))
  19.                     .mapToInt(Integer::parseInt)
  20.                     .toArray();
  21.             for (int i = 0; i < sequenceDNA.length; i++) {
  22.                 if (sequenceDNA[i] == 1) {
  23.                     seqSum += sequenceDNA[i];
  24.                     seqCounter++;
  25.                     //seqFirstPosition = i - seqCounter;
  26.                     if (seqCounter > seqLength) {
  27.                         seqLength = seqCounter;
  28.                     } else {
  29.                         seqCounter = 0;
  30.                     }
  31.                 }
  32.             }
  33.             break;
  34.         }
  35.         System.out.println("seqSum " + seqSum);
  36.         System.out.println("seqLength " + seqLength);
  37.         System.out.println("seqFirstPosition " + seqFirstPosition);
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement