import { ExtractNumbers } from "../common.ts"; /** * Parse the input for day 9 * * @param inputArr An array of strings containing numbers * @returns An array of histograms */ export function ParseInput(inputArr: string[]): Histogram[] { return inputArr.map((historyStr) => ExtractNumbers(historyStr) as Histogram); } /** * Find the difference of values in a histogram * * @param histogram A array of historical values, or another differential * @returns A new histogram containing the difference of values in the input histogram */ export function FindDifferential(histogram: Histogram): Histogram { const differential: Histogram = []; for (let i = 1; i < histogram.length; i++) { differential.push(histogram[i] - histogram[i - 1]); } return differential; } /** An array of historical environment values */ export type Histogram = number[];