Haskell
Not much time for challenges right now sadly :/
import Data.Bifunctor
import Data.IntSet qualified as IntSet
import Data.List.Split
repeats bound (from, to) = IntSet.elems $ IntSet.unions $ map go [2 .. bound l2]
where
l1 = length (show from)
l2 = length (show to)
go n =
let l = max 1 $ l1 `quot` n
start = if n > l1 then 10 ^ (l - 1) else read . take l $ show from
in IntSet.fromList
. takeWhile (<= to)
. dropWhile (< from)
. map (read . concat . replicate n . show)
$ enumFrom start
main = do
input <-
map (bimap read (read . tail) . break (== '-')) . splitOn ","
<$> readFile "input02"
let go bound = sum $ concatMap (repeats bound) input
print $ go (const 2)
print $ go id