aoc-2024/day_21/solve2.md
2024-12-23 04:15:04 +09:00

2.2 KiB

기본적인 정의를 합니다.

이제 헬퍼 함수를 정이합니다.

// \product is a function that returns a list of all possible combinations of two lists.
// \product :: path_set -> path_set -> path_set
// \product [] ys = []
// \product xs [] = []
// \product (x:xs) y = (concat x y) ++ (\product xs y)
// infix 5 \product // associativity is not important. because it commutative.

// ++ is union of two sets.
// concat :: cmd -> path_set -> path_set
// concat x [] = [x]
// concat x (y:ys) = (x:y) ++ (concat x ys)

// product :: path_set -> path_set -> path_set
// product a b = a \product b