Advent of Code #4 in Haskell - Ascending digits with double digit
Disclaimer: I don't know Haskell and I have never used it before.

solve low hi = length . takeWhile (&lt;= hi) . dropWhile (&lt; low) . map read .
  filter (allF [hasDouble, noLeadingZeros]) $ combinations 6 ['0'..'9']
  where hasDouble = any ((== 2) . length) . group
        noLeadingZeros = (/= '0') . head


Instead of running combinations 6 ['0'..'9'] and then chopping off everything which has a zero at the start, generate numbers from 100000..999999 and then convert it to a string. This would eliminate the combinations method.

I was able to make the following conclusions about the algorithm:


if the numbers are sorted from smallest to largest, then it should equal the original number (i.e. they are already sorted from smallest to greatest)
if the numbers with no duplicates does not equal the original number, then it means that there is at least two which were "de-duped", therefore it has two duplicates


I was able to produce the following code:

import Data.List

checkNum num = do return ((sort(show num) == (show num) &amp;&amp; (nub (show num)) /= (show num)))
main = do checkNum 4222211


This checks if the sorted number (as a string) is equal to itself (which means that it is increasing correctly), and nub removes all duplicate digits.