import { CharColl, Collection } from "util/collection";

// If blank strings/ints is not enough
export const inputMapper = (inputs: string) => inputs;

export function solution1(inputs: Collection<string>): number {
  const flat: Collection<string> = CharColl(inputs[0]);

  for (let i = 4; i < flat.length; i++) {
    const distinct = new Set(flat.slice(i - 4, i)).size;

    if (distinct === 4) {
      return i;
    }
  }

  return 0;
}

export function solution2(inputs: Collection<string>): number {
  const flat: Collection<string> = CharColl(inputs[0]);

  for (let i = 14; i < flat.length; i++) {
    const distinct = new Set(flat.slice(i - 14, i)).size;

    if (distinct === 14) {
      return i;
    }
  }

  return 0;
}
