Hands of Straights (LeetCode) Arrange the card
Lines like False -&gt; False indicate that there is a better way.

helper :: Int -&gt; [[Int]] -&gt; Bool
helper v [] = True
helper v xss = let (a, b) = splitAt v xss 
  in verify a &amp;&amp; length a `mod` v == 0 -- length a &lt;= v, so why not just length a == v?
  &amp;&amp; helper v (removeHead a [] ++ b)

removeHead :: [[Int]] -&gt; [[Int]] -&gt; [[Int]]
removeHead [] acc = acc
removeHead (x:xss) acc = removeHead xss
  $ acc ++ [tail x | not $ null $ tail x]


Left folds like removeHead can often be turned into right folds:

removeHead :: [[Int]] -&gt; [[Int]]
removeHead [] = []
removeHead (x:xss) = [tail x | not $ null $ tail x] ++ removeHead xss


removeHead needs no explicit recursion. Data.List.NonEmpty lets us avoid partial functions (and giving verify a name :) ).

import Data.List.NonEmpty

solve :: Int -&gt; [Int] -&gt; Bool
solve v = helper v . NE.group . sort

helper :: Int -&gt; [NE.NonEmpty Int] -&gt; Bool
helper v [] = True
helper v xss =
  let (a, b) = splitAt v xss
      (straight, a') = unzip $ map NE.uncons a
  in all (==1) (zipWith subtract straight (tail straight))
  &amp;&amp; length a == v
  &amp;&amp; helper v (catMaybes a' ++ b)