Advertisement
Guest User

Untitled

a guest
Dec 2nd, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. >>> f(3)
  2. 0010111
  3.  
  4. >>> f(3)
  5. 0123456789876543210
  6.  
  7. >>> f(3)
  8. 001010011110111
  9.  
  10. import java.util.Scanner;
  11. import java.util.ArrayList;
  12.  
  13. public class Checker {
  14. public static void main(String[] args) throws Exception {
  15. int substringLength = Integer.parseInt(args[0]);
  16.  
  17. Scanner sc = new Scanner(System.in);
  18. sc.useDelimiter("");
  19.  
  20. ArrayList<Character[]> active = new ArrayList<Character[]>();
  21.  
  22. Character[] current = new Character[substringLength],
  23. compare, prev;
  24.  
  25. for (int i = 0; i < substringLength; i++) {
  26. current[i] = sc.next().charAt(0);
  27. }
  28.  
  29. for (int index = 0; sc.hasNext(); index++) {
  30. for (int k = 0; k < index; k++) {
  31. boolean differ = false;
  32. compare = active.get(k);
  33. for (int j = 0; j < substringLength; j++) {
  34. differ = differ || compare[j].compareTo(current[j]) != 0;
  35. }
  36. if (!differ)
  37. throw new Exception("Match found for subset " + index);
  38. }
  39. active.add(current);
  40. prev = current;
  41. current = new Character[substringLength];
  42. for (int k = 1; k < substringLength; k++) {
  43. current[k - 1] = prev[k];
  44. }
  45. current[substringLength - 1] = sc.next().charAt(0);
  46. }
  47.  
  48. System.out.println("Input is a valid version series.");
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement