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

export function solution1(inputs: string[]): number {
  const winning = ["A Y", "B Z", "C X"];
  const tie = ["A X", "B Y", "C Z"];

  return inputs.filter((input) => winning.includes(input)).length * 6 +
    inputs.filter((input) => tie.includes(input)).length * 3 +
    inputs.filter((input) => input.includes("X")).length +
    inputs.filter((input) => input.includes("Y")).length * 2 +
    inputs.filter((input) => input.includes("Z")).length * 3;
}

export function solution2(inputs: string[]): number {
  const getWinning = {
    A: "Y",
    B: "Z",
    C: "X",
  } as const;

  const getLosing = {
    A: "Z",
    B: "X",
    C: "Y",
  } as const;

  const getTie = {
    A: "X",
    B: "Y",
    C: "Z",
  } as const;

  const solution1Format = inputs.map((i) => {
    const [move, result] = i.split(" ") as [
      ("A" | "B" | "C"),
      ("X" | "Y" | "Z"),
    ];

    // Need to lose
    if (result === "X") {
      return `${move} ${getLosing[move]}`;
    } else if (result === "Y") {
      return `${move} ${getTie[move]}`;
    } else {
      return `${move} ${getWinning[move]}`;
    }
  });

  return solution1(solution1Format);
}
