Originally, I thought I need some kind of constraint programming, but the problem size is small enough that I can brute-force it… The complete code
looks fairly succinct.
predicate list = and $ [ sum == (list !! 1 + list !! 2 + list !! 3) , sum == (list !! 3 + list !! 4 + list !! 5) , sum == (list !! 5 + list !! 6 + list !! 7) , sum == (list !! 5 + list !! 6 + list !! 7) , sum == (list !! 7 + list !! 8) ] where sum = get_sum list