diff --git a/day6.erl b/day6.erl new file mode 100644 index 0000000..4e61fc6 --- /dev/null +++ b/day6.erl @@ -0,0 +1,15 @@ +-module(day6). + +-export([solve/1]). + +solve(InputData) -> + {solve(InputData, 1), none}. + +solve(<>, N) -> solve(<>, N+1); +solve(<>, N) -> solve(<>, N+1); +solve(<>, N) -> solve(<>, N+1); +solve(<>, N) -> solve(<>, N+2); +solve(<>, N) -> solve(<>, N+3); +solve(<>, N) when A /= B andalso B /= C andalso C /= D andalso + A /= C andalso B /= D andalso A /= D -> N+3; +solve(<<_, Rest/binary>>, N) -> solve(Rest, N+1).