static List<Interval> getIntervals(String input) {
    List<Interval> intervals = new ArrayList<Interval>();
    
    int start = -1;
    for (int i = 0; i < input.length(); i++) {
      if (input.charAt(i) == '.' && start == -1) {
        start = i;
      } else if (input.charAt(i) == 'X') {
        if (start != -1) {
          intervals.add(new Interval(start, i - 1));
        }
        start = -1;
      }
    }
    if (start != -1) {
      intervals.add(new Interval(start, input.length() - 1));
    }
    
    return intervals;
  }